commit 646c35648ffb74669d1c811b7ba0ca65cae22956
parent 7ae7cc3579c99a3466d37ebbadca47127d0b4f53
Author: Dan Stillman <dstillman@zotero.org>
Date: Tue, 5 Jan 2010 08:51:44 +0000
- 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)
Diffstat:
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
@@ -1359,7 +1359,8 @@ Zotero.Item.prototype.save = function() {
var parent = this.isNote() ? this.getSource() : null;
var noteText = this._noteText ? this._noteText : '';
// Add <div> wrapper if not present
- if (!noteText.match(/^<div class="zotero-note znv[0-9]+">[\s\S]*<\/div>$/)) {
+ if (!noteText.substr(0, 36).match(/^<div class="zotero-note znv[0-9]+">/)) {
+ // Keep consistent with getNote()
noteText = '<div class="zotero-note znv1">' + noteText + '</div>';
}
@@ -2307,20 +2308,22 @@ Zotero.Item.prototype.getNote = function() {
// Convert non-HTML notes on-the-fly
if (note) {
- if (!note.match(/^<div class="zotero-note znv[0-9]+">[\s\S]*<\/div>$/)) {
+ if (!note.substr(0, 36).match(/^<div class="zotero-note znv[0-9]+">/)) {
note = Zotero.Utilities.prototype.htmlSpecialChars(note);
- note = '<p>'
+ note = '<div class="zotero-note znv1"><p>'
+ note.replace(/\n/g, '</p><p>')
.replace(/\t/g, ' ')
.replace(/ /g, ' ')
- + '</p>';
+ + '</p></div>';
note = note.replace(/<p>\s*<\/p>/g, '<p> </p>');
var sql = "UPDATE itemNotes SET note=? WHERE itemID=?";
Zotero.DB.query(sql, [note, this.id]);
}
// Don't include <div> wrapper when returning value
- note = note.replace(/^<div class="zotero-note znv[0-9]+">([\s\S]*)<\/div>$/, '$1');
+ var startLen = note.substr(0, 36).match(/^<div class="zotero-note znv[0-9]+">/)[0].length;
+ var endLen = 6; // "</div>".length
+ note = note.substr(startLen, note.length - endLen);
}
this._noteText = note ? note : '';