diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js index d5c52e6fc0..f035c13a22 100644 --- a/chrome/content/zotero/xpcom/data/item.js +++ b/chrome/content/zotero/xpcom/data/item.js @@ -1359,7 +1359,8 @@ Zotero.Item.prototype.save = function() { var parent = this.isNote() ? this.getSource() : null; var noteText = this._noteText ? this._noteText : ''; // Add
wrapper if not present - if (!noteText.match(/^
[\s\S]*<\/div>$/)) { + if (!noteText.substr(0, 36).match(/^
/)) { + // Keep consistent with getNote() noteText = '
' + noteText + '
'; } @@ -2307,20 +2308,22 @@ Zotero.Item.prototype.getNote = function() { // Convert non-HTML notes on-the-fly if (note) { - if (!note.match(/^
[\s\S]*<\/div>$/)) { + if (!note.substr(0, 36).match(/^
/)) { note = Zotero.Utilities.prototype.htmlSpecialChars(note); - note = '

' + note = '

' + note.replace(/\n/g, '

') .replace(/\t/g, '    ') .replace(/ /g, '  ') - + '

'; + + '

'; note = note.replace(/

\s*<\/p>/g, '

 

'); var sql = "UPDATE itemNotes SET note=? WHERE itemID=?"; Zotero.DB.query(sql, [note, this.id]); } // Don't include
wrapper when returning value - note = note.replace(/^
([\s\S]*)<\/div>$/, '$1'); + var startLen = note.substr(0, 36).match(/^
/)[0].length; + var endLen = 6; // "
".length + note = note.substr(startLen, note.length - endLen); } this._noteText = note ? note : '';