freeCodeCamp/client/src/utils
Erik Krogh Kristensen 11dfe9274f
fix catastrophic backtracking when removing HTML comments (#40223)
* fix catastrophic backtracking when removing HTML comments

The regexp `/<!--(.|\s)*?-->/g` can experience catastrophic backtracking while matching a string like `<!--                                           -- >` (notice how it does not end with `-->`).    

[You can see the catastrophic backtracking in action here](https://regex101.com/r/2jvwFi/1/debugger). 

This is because both `.` and `\s` matches the space character, and there are therefore a large number of possible ways for `(.|\s)*` to match a long sequence of spaces.  
The regexp evaluator is greedy, and the problem therefore only exists when the string does not match the regexp. 

The fix is simply to remove the ambiguity such that there is only one possible way for the regexp to match a sequence of white-space.

* Update client/src/utils/curriculum-helpers.js

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
2020-11-12 08:20:34 -08:00
..
__fixtures feat(client, learn): add helper functions for common validation operations (#38605) 2020-09-17 19:38:01 +05:30
ajax.js fix(client): unify client donations methods (#39562) 2020-10-14 15:53:26 +05:30
createTypes.js chore(client): Move client app to /client 2018-09-03 17:47:48 +05:30
curriculum-helpers.js fix catastrophic backtracking when removing HTML comments (#40223) 2020-11-12 08:20:34 -08:00
curriculum-helpers.test.js feat(client, learn): add helper functions for common validation operations (#38605) 2020-09-17 19:38:01 +05:30
format.js fix: use util.inspect for more reliable logging (#37880) 2019-12-06 08:37:10 -08:00
format.test.js fix: use util.inspect for more reliable logging (#37880) 2019-12-06 08:37:10 -08:00
get-words.js fix: updated and consolidated quotes (#39069) 2020-06-15 18:42:27 +05:30
handled-error.js feat: simplify landing page 2019-09-04 18:23:21 +05:30
handled-error.test.js feat(donate): PayPal integration 2020-03-16 18:35:51 +05:30
index.js feat: remove news from platform 2019-01-16 13:48:38 +00:00
reallyWeirdErrorMessage.js fix(client):remove hyperlink from flash message (#38429) 2020-03-24 17:31:48 +01:00
report-error.js chore: remove rollbar from client and .env 2020-03-26 16:51:17 +05:30
reportedErrorMessage.js Feat: News in the client app (#34392) 2018-11-29 15:12:15 +03:00
scriptLoaders.js fix: remove remnants of servicebot 2020-09-04 00:14:24 +05:30
standardErrorMessage.js feat(certs): Convert certification views to gatsby 2018-09-04 19:40:07 +05:30