diff --git a/lib/data/dataset.js b/lib/data/dataset.js index 88491b3de..655e5b5da 100644 --- a/lib/data/dataset.js +++ b/lib/data/dataset.js @@ -36,12 +36,12 @@ const validatePropertyName = (name) => { // (similar to above dataset name check with some slight differences) // Check for a match with a valid string // (?!__) is negative lookahead to check string does not start with double underscore __ - // (?!name$)(?!label$) negative lookahead for "name" and "label" specifically + // (?!name$)(?!label$) negative lookahead for "name" and "label" specifically, insensitive to case // [\p{L}_] valid start character of unicode letter or _ (no :) // [\p{L}\d\\._-]* more characters from valid starting character set, digits, hyphens, and '.' // If there's a match, return true (valid)! // Non-letter unicode characters also not currently allowed - const match = /^(?!__)(?!name$)(?!label$)[\p{L}_][\p{L}\d._-]*$/u.exec(name); + const match = /^(?!__)(?!name$)(?!label$)[\p{L}_][\p{L}\d._-]*$/u.exec(name.toLowerCase()); return (match !== null); }; diff --git a/test/unit/data/dataset.js b/test/unit/data/dataset.js index 1e800ee34..48c7a9d54 100644 --- a/test/unit/data/dataset.js +++ b/test/unit/data/dataset.js @@ -310,6 +310,12 @@ describe('property name validation', () => { validatePropertyName('label').should.equal(false); }); + it('should reject name or label in case-insensitive way', () => { + validatePropertyName('Name').should.equal(false); + validatePropertyName('NaMe').should.equal(false); + validatePropertyName('LABEL').should.equal(false); + }); + it('should reject name with whitespace at the ends', () => { validatePropertyName(' bad_whitespace ').should.equal(false); });