From d904470200bb3ead270db8d3baa7392ee48810ec Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sat, 14 Mar 2009 21:48:47 +0000 Subject: [PATCH] Fixes #1393, "Error when adding existing tag beginning with certain extended characters to an item", but not properly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SQLite's COLLATE NOCASE doesn't work for Unicode characters, so it won't find existing tag "Äbc" if "äbc" is entered and will allow a duplicate tag to be created --- chrome/content/zotero/xpcom/data/tags.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/chrome/content/zotero/xpcom/data/tags.js b/chrome/content/zotero/xpcom/data/tags.js index 04d25ec75a..e414cf20db 100644 --- a/chrome/content/zotero/xpcom/data/tags.js +++ b/chrome/content/zotero/xpcom/data/tags.js @@ -74,12 +74,16 @@ Zotero.Tags = new function() { * Returns the tagID matching given tag and type */ function getID(name, type) { - name = Zotero.Utilities.prototype.trim(name).toLowerCase(); + name = Zotero.Utilities.prototype.trim(name); + var lcname = name.toLowerCase(); - if (_tags[type] && _tags[type]['_' + name]) { - return _tags[type]['_' + name]; + if (_tags[type] && _tags[type]['_' + lcname]) { + return _tags[type]['_' + lcname]; } + // FIXME: COLLATE NOCASE doesn't work for Unicode characters, so this + // won't find Äbc if "äbc" is entered and will allow a duplicate tag + // to be created var sql = 'SELECT tagID FROM tags WHERE name=? AND type=?'; var tagID = Zotero.DB.valueQuery(sql, [name, type]); @@ -87,7 +91,7 @@ Zotero.Tags = new function() { if (!_tags[type]) { _tags[type] = []; } - _tags[type]['_' + name] = tagID; + _tags[type]['_' + lcname] = tagID; } return tagID;