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;