Skip to content

Commit ae1e4c8

Browse files
rewriting regular expression to avoid catastrophic backtracking (#222)
* rewriting regulare expression to avoid catastrophic backtracking * updating to released version of @oracle/wrc-jet-pack
1 parent 086db50 commit ae1e4c8

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

webui/package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
"dependencies": {
1313
"@oracle/oraclejet": "^13.1.7",
14-
"@oracle/wrc-jet-pack": "^2.4.2-develop.202303162018",
14+
"@oracle/wrc-jet-pack": "~2.4.2",
1515
"ace-builds": "^1.15.0",
1616
"i18next": "^22.4.9",
1717
"jquery": "^3.6.3",

webui/src/js/utils/validation-helper.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,25 @@ function(i18n, Validator, ojvalidationError, RegExpValidator, LengthValidator, N
1212

1313
const literalForwardSlash = '[\\/]';
1414

15-
const nameComponentRegexText = '(?:(?:[a-z0-9]+)(?:(?:[._]|__|[-]?)(?:[a-z0-9]+))*)';
16-
const hostRegexText = '(?:(?:[a-zA-Z0-9]+|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])' +
17-
'(?:(?:[.](?:[a-zA-Z0-9]+|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]))+)?)';
15+
const compNameRegexText = '[a-z0-9]+';
16+
const compNameSeparatorRegexText = '(?:[.]|[_]{1,2}|[-]+)';
17+
const nameComponentRegexText = `${compNameRegexText}(?:${compNameSeparatorRegexText}${compNameRegexText})*`;
18+
const hostRegexText = '[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?(?:[.][a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?)*';
1819
const hostAndPortRegexText = `(?:${hostRegexText}(?:[:][0-9]{1,5})?)`;
1920
const tagRegexText = '[\\w][\\w.-]{0,127}';
2021
const digestRegexText = '[A-Za-z][A-Za-z0-9]*(?:(?:[-_+.][A-Za-z][A-Za-z0-9]*)*)[:][0-9A-Fa-f]{32,}';
21-
const nameRegexText = `(?:(${hostAndPortRegexText})${literalForwardSlash})?${nameComponentRegexText}` +
22+
const nameRegexText = `(?:(?:${hostAndPortRegexText})${literalForwardSlash})?${nameComponentRegexText}` +
2223
`(?:${literalForwardSlash}${nameComponentRegexText})*`;
23-
const imageReferenceRegexText = `^(${nameRegexText})(?:(?:[:](${tagRegexText}))|(?:[@](${digestRegexText})))?$`;
24+
const imageReferenceRegexText = `(?:${nameRegexText})(?:(?:[:](?:${tagRegexText}))|(?:[@](?:${digestRegexText})))?`;
2425

25-
const k8sNameRegexText = '^[a-z0-9](?:[-a-z0-9]{0,61}[a-z0-9])?$';
26+
const k8sNameRegexText = '[a-z0-9](?:[-a-z0-9]{0,61}[a-z0-9])?';
2627

27-
const emailAddressRegexText = '^(?:[a-z0-9!#$%&\'*+\\/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&\'*+\\/=?^_`{|}~-]+)*|' +
28+
const emailAddressRegexText = '(?:[a-z0-9!#$%&\'*+\\/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&\'*+\\/=?^_`{|}~-]+)*|' +
2829
'"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*")@' +
2930
'(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|' +
3031
'\\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\\.){3}' +
3132
'(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:' +
32-
'(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])$';
33+
'(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])';
3334

3435
const ingressPathRegexText = '^\\/\\S*$';
3536

0 commit comments

Comments
 (0)