From 49d5c1fd31eafb2964e3bdc9eb7f10834f3efdcb Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 17 Mar 2011 21:34:59 +0000 Subject: [PATCH] Prevent erroneous conflicts due to Windows newlines in imported notes (which should be fixed separately) Using a try/catch to prevent unexpected errors in 2.1 Final --- chrome/content/zotero/xpcom/data/item.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js index a63556d42b..a5dd112fb0 100644 --- a/chrome/content/zotero/xpcom/data/item.js +++ b/chrome/content/zotero/xpcom/data/item.js @@ -3679,7 +3679,18 @@ Zotero.Item.prototype.diff = function (item, includeMatches, ignoreFields) { } if (thisData.note != undefined) { - changed = thisData.note != otherData.note; + // replace() keeps Windows newlines from triggering erroneous conflicts, + // though this should really be fixed at the data layer level + // + // Using a try/catch to avoid unexpected errors in 2.1 Final + try { + changed = thisData.note.replace(/\r\n/g, "\n") != otherData.note.replace(/\r\n/g, "\n"); + } + catch (e) { + Zotero.debug(e); + Components.utils.reportError(e); + changed = thisData.note != otherData.note; + } if (includeMatches || changed) { diff[0].note = thisData.note; diff[1].note = otherData.note;