Conversation
The urlCompatible validator used the character class [\d,a-z,-], where the commas are literal characters rather than separators, so a route id such as "a,b" passed validation despite the "only lowercase letters, numbers and dash" rule (js/regex/duplicate-in-character-class). Also drop a redundant truthiness check in createTreeNavigation (js/trivial-conditional).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes code scanning alerts #68 (
js/regex/duplicate-in-character-class) and #67 (js/trivial-conditional), both warnings inopenig-ui.#68 — a real validation bug
The
urlCompatiblevalidator (used for the routeidfield in Studio) tested against/^[\d,a-z,-]+$/. Inside a character class the commas are literal characters, not separators, so an id likea,bpassed validation — contrary to the i18n message "Use only lowercase letters, numbers and dash" and togenerateRouteId(), which strips such characters. The class is now[\da-z-].A
"bad,id"→ invalid case is added toOpenIGValidatorsTests.js.#67 — cosmetic
createTreeNavigation.js:else if (data && !_.isArray(data))→else if (!_.isArray(data));datais already known to be truthy in that branch.Verification
grunt build(eslint + babel + requirejs) passes.Note on the QUnit suite:
grunt qunit(grunt-contrib-qunit 1.3 / PhantomJS) times out locally and thequnittask is commented out of thebuildtask, so the JS tests are not executed by the Maven build. To still get a red/green signal, the validator module was loaded in Node through a minimal AMD shim and exercised with every value from the QUnit test: before the fix'bad,id' -> valid, after itinvalid, the other seven cases unchanged. Reviving the QUnit runner (headless Chrome instead of PhantomJS) is a separate task.