mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 01:13:23 -04:00
[Search][ES3] Fix polynomial regex (#202508)
## Summary The expression here violates [polynomial regular expression used on uncontrolled data](https://codeql.github.com/codeql-query-help/javascript/js-polynomial-redos/) This PR replaces the problem regex with one that is not ambiguous about when to start matching `-` sequences. This is done through using a negative look-behind.
This commit is contained in:
parent
30ceb1a053
commit
686e356d96
1 changed files with 1 additions and 1 deletions
|
@ -11,5 +11,5 @@ export const toAlphanumeric = (input: string) =>
|
|||
input
|
||||
.trim()
|
||||
.replace(/[^a-zA-Z0-9]+/g, '-') // Replace all special/non-alphanumerical characters with dashes
|
||||
.replace(/^[-]+|[-]+$/g, '') // Strip all leading and trailing dashes
|
||||
.replace(/(^-+|(?<!-)-+$)/g, '') // Strip all leading and trailing dashes
|
||||
.toLowerCase();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue