From 646c35648ffb74669d1c811b7ba0ca65cae22956 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 5 Jan 2010 08:51:44 +0000 Subject: [PATCH] - Fix "script stack space quota is exhausted" error with extremely large notes - Fix repeated text-to-HTML conversion of unedited plaintext notes (which might exist at this point only from direct DB writes) --- chrome/content/zotero/xpcom/data/item.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js index d5c52e6fc..f035c13a2 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 : '';