Fix startup hang if note is null in database
(cherry picked from commit 2194dff7a4
)
This commit is contained in:
parent
1bdb329bc8
commit
be300ec62b
|
@ -415,21 +415,31 @@ Zotero.Items = function() {
|
||||||
|
|
||||||
// Convert non-HTML notes on-the-fly
|
// Convert non-HTML notes on-the-fly
|
||||||
if (note !== "") {
|
if (note !== "") {
|
||||||
if (!note.substr(0, 36).match(/^<div class="zotero-note znv[0-9]+">/)) {
|
if (typeof note == 'number') {
|
||||||
note = Zotero.Utilities.htmlSpecialChars(note);
|
note = '' + note;
|
||||||
note = Zotero.Notes.notePrefix + '<p>'
|
|
||||||
+ note.replace(/\n/g, '</p><p>')
|
|
||||||
.replace(/\t/g, ' ')
|
|
||||||
.replace(/ /g, ' ')
|
|
||||||
+ '</p>' + Zotero.Notes.noteSuffix;
|
|
||||||
note = note.replace(/<p>\s*<\/p>/g, '<p> </p>');
|
|
||||||
notesToUpdate.push([item.id, note]);
|
|
||||||
}
|
}
|
||||||
|
if (typeof note == 'string') {
|
||||||
|
if (!note.substr(0, 36).match(/^<div class="zotero-note znv[0-9]+">/)) {
|
||||||
|
note = Zotero.Utilities.htmlSpecialChars(note);
|
||||||
|
note = Zotero.Notes.notePrefix + '<p>'
|
||||||
|
+ note.replace(/\n/g, '</p><p>')
|
||||||
|
.replace(/\t/g, ' ')
|
||||||
|
.replace(/ /g, ' ')
|
||||||
|
+ '</p>' + Zotero.Notes.noteSuffix;
|
||||||
|
note = note.replace(/<p>\s*<\/p>/g, '<p> </p>');
|
||||||
|
notesToUpdate.push([item.id, note]);
|
||||||
|
}
|
||||||
|
|
||||||
// Don't include <div> wrapper when returning value
|
// Don't include <div> wrapper when returning value
|
||||||
let startLen = note.substr(0, 36).match(/^<div class="zotero-note znv[0-9]+">/)[0].length;
|
let startLen = note.substr(0, 36).match(/^<div class="zotero-note znv[0-9]+">/)[0].length;
|
||||||
let endLen = 6; // "</div>".length
|
let endLen = 6; // "</div>".length
|
||||||
note = note.substr(startLen, note.length - startLen - endLen);
|
note = note.substr(startLen, note.length - startLen - endLen);
|
||||||
|
}
|
||||||
|
// Clear null notes
|
||||||
|
else {
|
||||||
|
note = '';
|
||||||
|
notesToUpdate.push([item.id, '']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
item._noteText = note ? note : '';
|
item._noteText = note ? note : '';
|
||||||
|
|
Loading…
Reference in New Issue
Block a user