www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit a4cd45ceb400ef742ce980e5331dca3e40625b8a
parent 6fb99d2d90a96c59b90c43b5d32f51da04b28e48
Author: Dan Stillman <dstillman@zotero.org>
Date:   Thu, 26 Apr 2018 02:14:37 -0400

Exclude note prefix and suffix when searching

This avoids having "1" match all notes (though really we should be
searching on a plain-text string stored in a separate column).

Diffstat:
Mchrome/content/zotero/xpcom/data/item.js | 3+--
Mchrome/content/zotero/xpcom/data/searchConditions.js | 8++++++--
2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js @@ -1644,8 +1644,7 @@ Zotero.Item.prototype._saveData = Zotero.Promise.coroutine(function* (env) { let noteText = this._noteText ? this._noteText : ''; // Add <div> wrapper if not present if (!noteText.match(/^<div class="zotero-note znv[0-9]+">[\s\S]*<\/div>$/)) { - // Keep consistent with getNote() - noteText = '<div class="zotero-note znv1">' + noteText + '</div>'; + noteText = Zotero.Notes.notePrefix + noteText + Zotero.Notes.noteSuffix; } let params = [ diff --git a/chrome/content/zotero/xpcom/data/searchConditions.js b/chrome/content/zotero/xpcom/data/searchConditions.js @@ -338,7 +338,9 @@ Zotero.SearchConditions = new function(){ doesNotContain: true }, table: 'itemNotes', - field: 'note' + // Exclude note prefix and suffix + field: `SUBSTR(note, ${1 + Zotero.Notes.notePrefix.length}, ` + + `LENGTH(note) - ${Zotero.Notes.notePrefix.length + Zotero.Notes.noteSuffix.length})` }, { @@ -348,7 +350,9 @@ Zotero.SearchConditions = new function(){ doesNotContain: true }, table: 'items', - field: 'note' + // Exclude note prefix and suffix + field: `SUBSTR(note, ${1 + Zotero.Notes.notePrefix.length}, ` + + `LENGTH(note) - ${Zotero.Notes.notePrefix.length + Zotero.Notes.noteSuffix.length})` }, {