freeCodeCamp/client
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
..
config fix(build): Make build unrelient on root level deps (take 2) 2018-09-06 16:07:03 +01:00
plugins fix: watch curriculum changes 2020-09-29 22:09:02 +02:00
src fix catastrophic backtracking when removing HTML comments (#40223) 2020-11-12 08:20:34 -08:00
static refactor(learn): remove static prism css (#39981) 2020-10-15 18:13:51 +05:30
utils feat: update Ask for help (#40114) 2020-10-30 14:10:34 -05:00
.babelrc feat(client): show line numbers on video questions (#39207) 2020-07-08 20:00:42 +05:30
.gitignore fix(client): add cache-busting hashes to chunks (#37746) 2019-11-15 01:43:44 +05:30
gatsby-browser.js fix: save the fonts locally 2019-10-16 19:29:48 +09:00
gatsby-config.js fix(client): ensure validation works during watch (#38936) 2020-05-28 20:54:29 +05:30
gatsby-node.js refactor: use dashedName over dasherize(title) 2020-10-06 23:10:08 +05:30
gatsby-ssr.js feat: enable MathJax for Project Euler challenges (#38017) 2020-01-07 14:14:12 +03:00
jest.config.js refactor(client): move jest-dom into setup file 2020-10-12 14:11:52 +02:00
jest.setup.js refactor(client): move jest-dom into setup file 2020-10-12 14:11:52 +02:00
jest.transform.js feat: Use prettier-eslint to format code 2019-02-19 14:30:27 +05:30
package-lock.json chore(deps): bump gatsby-remark-prismjs from 3.5.16 to 3.6.0 in /client 2020-11-09 08:25:24 +00:00
package.json chore(deps): bump gatsby-remark-prismjs from 3.5.16 to 3.6.0 in /client 2020-11-09 08:25:24 +00:00
postcss.config.js feat: commandline chic 2019-08-20 13:37:11 +05:30
webpack-workers.js fix(client): add cache-busting hashes to chunks (#37746) 2019-11-15 01:43:44 +05:30