From beaaf8fc6b31b8471bcf13f169611b92212f7e8b Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 4 Jan 2013 13:00:26 -0500 Subject: [PATCH] Accept two missing letters in object keys (but don't use them yet) Also: - 'T' doesn't come after 'X' (but does probably appear disproportionally in existing object keys) This commit has been brought to you by the letters 'L' and 'Y'. --- chrome/content/zotero/xpcom/data/creator.js | 3 +-- chrome/content/zotero/xpcom/id.js | 9 ++++++++- chrome/content/zotero/xpcom/utilities.js | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/chrome/content/zotero/xpcom/data/creator.js b/chrome/content/zotero/xpcom/data/creator.js index 4aeace7d2..c9051d8b8 100644 --- a/chrome/content/zotero/xpcom/data/creator.js +++ b/chrome/content/zotero/xpcom/data/creator.js @@ -536,8 +536,7 @@ Zotero.Creator.prototype._checkValue = function (field, value) { break; case 'key': - var re = /^[23456789ABCDEFGHIJKMNPQRSTUVWXTZ]{8}$/ - if (!re.test(value)) { + if (!Zotero.ID.isValidKey(value)) { this._invalidValueError(field, value); } break; diff --git a/chrome/content/zotero/xpcom/id.js b/chrome/content/zotero/xpcom/id.js index 9d56aa97d..17c85a8ac 100644 --- a/chrome/content/zotero/xpcom/id.js +++ b/chrome/content/zotero/xpcom/id.js @@ -87,11 +87,18 @@ Zotero.ID_Tracker = function () { function getKey() { - var baseString = "23456789ABCDEFGHIJKMNPQRSTUVWXTZ"; + // TODO: add 'L' and 'Y' after 3.0.11 cut-off + var baseString = "23456789ABCDEFGHIJKMNPQRSTUVWXZ"; return Zotero.randomString(8, baseString); } + this.isValidKey = function () { + var re = /^[23456789ABCDEFGHIJKLMNPQRSTUVWXYZ]{8}$/ + return re.test(value); + } + + function getBigInt(max) { if (!max) { max = 9007199254740991; diff --git a/chrome/content/zotero/xpcom/utilities.js b/chrome/content/zotero/xpcom/utilities.js index e2f3cab5b..3e90cb807 100644 --- a/chrome/content/zotero/xpcom/utilities.js +++ b/chrome/content/zotero/xpcom/utilities.js @@ -1069,7 +1069,7 @@ Zotero.Utilities = { **/ "randomString":function(len, chars) { if (!chars) { - chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz"; + chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghiklmnopqrstuvwxyz"; } if (!len) { len = 8;