Skip to content
This repository has been archived by the owner on Feb 14, 2024. It is now read-only.

Commit

Permalink
fix(project): do not allow placeholders in IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
Oğuz Eroğlu authored and nikku committed Dec 10, 2019
1 parent 2d1cbc6 commit 799938e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 15 deletions.
15 changes: 1 addition & 14 deletions lib/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ var QNAME_REGEX = /^([a-z][\w-.]*:)?[a-z_][\w-.]*$/i;
// for ID validation as per CMMN Schema (QName - Namespace)
var ID_REGEX = /^[a-z_][\w-.]*$/i;

var PLACEHOLDER_REGEX = /\$\{([^}]*)\}/g;

var HTML_ESCAPE_MAP = {
'&': '&',
'<': '&lt;',
Expand Down Expand Up @@ -55,8 +53,6 @@ module.exports.isIdValid = isIdValid;

function validateId(idValue) {

idValue = stripPlaceholders(idValue);

if (containsSpace(idValue)) {
return 'Id must not contain spaces.';
}
Expand All @@ -80,15 +76,6 @@ function containsSpace(value) {

module.exports.containsSpace = containsSpace;


function stripPlaceholders(idValue) {

// replace expression e.g. ${VERSION_TAG}
// use only the content between ${}
// for the REGEX check
return idValue.replace(PLACEHOLDER_REGEX, '$1');
}

/**
* generate a semantic id with given prefix
*/
Expand Down Expand Up @@ -135,4 +122,4 @@ function escapeHTML(str) {
});
}

module.exports.escapeHTML = escapeHTML;
module.exports.escapeHTML = escapeHTML;
2 changes: 1 addition & 1 deletion test/spec/UtilsSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('Utils', function() {
it('may NOT start with numbers', validate('9ba', 'Id must be a valid QName.'));
it('may NOT start prefix with numbers', validate('9ba:foo', 'Id must be a valid QName.'));

it('may contain ${} placeholders', validate('${foo}ba99'));
it('may NOT contain ${} placeholders', validate('${foo}ba99', 'Id must be a valid QName.'));
it('may NOT contain empty placeholders', validate('${}', 'Id must be a valid QName.'));
});

Expand Down

0 comments on commit 799938e

Please sign in to comment.