freeCodeCamp/client/src
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
..
__mocks__ chore: remove isRequired from curriculum files 2020-09-21 20:51:46 +05:30
__tests__/integration feat: remove news from platform 2019-01-16 13:48:38 +00:00
analytics chore: Port over mission statement and gtag (#34262) 2018-11-09 21:21:50 +05:30
assets fix(client): address new warnings from linter 2020-10-12 15:10:42 +05:30
client feat(client, learn): add helper functions for common validation operations (#38605) 2020-09-17 19:38:01 +05:30
client-only-routes feat(api): allow redirects with a returnTo param (#40161) 2020-11-07 13:35:25 +05:30
components feat: update donation plans on donate page. (#40102) 2020-11-06 17:00:14 +05:30
head fix: update meta (#39500) 2020-08-31 20:41:13 -05:00
pages feat: update donation plans on donate page. (#40102) 2020-11-06 17:00:14 +05:30
redux feat: update Ask for help (#40114) 2020-10-30 14:10:34 -05:00
resources fix: qa project links on settings page (#40169) 2020-11-04 14:01:57 +05:30
templates fix(learn): reload when challenge tests change (#39832) 2020-11-02 11:22:01 -06:00
utils fix catastrophic backtracking when removing HTML comments (#40223) 2020-11-12 08:20:34 -08:00
html.js revert: "fix: ensure 'night' is set before hydration" 2019-09-11 23:20:01 +05:30