Skip to content

fix: push '\' into className before regex special characters - #640

Merged
Anber merged 3 commits into
callstack:masterfrom
SeokminHong:master
Sep 3, 2020
Merged

Anber merged 3 commits into
callstack:masterfrom
SeokminHong:master

Conversation

@SeokminHong

Copy link
Copy Markdown
Contributor

Motivation

When I use a HTML elements containing regex's special characters(\, $, and so on) for class, extractClassesFromHtml function fails to parse them.

Summary

extractClassesFromHtml returns a regex array for matching class, thus I added escape characters(\) before the special characters.

Test plan

Try to parse the HTML document having class containing following characters for its class:

\, ^, $, {, }, [, ], (, ), ., *, +, ?, |

For example: <code class="language-C++">

* The `extractClassesFromHtml` function can fail to parse the some HTMLs because they have class names including special characters for regular expression.
@callstack-bot

callstack-bot commented Jul 18, 2020 •

Copy link
Copy Markdown

Hey @SeokminHong, thank you for your pull request 🤗.
The coverage report for this branch can be viewed here.

@iamakulov

Copy link
Copy Markdown

Just stumbled upon the same error! Would love to see this merged. How can I help?

@Anber
Anber merged commit 7c322a4 into callstack:master Sep 3, 2020
Anber pushed a commit that referenced this pull request Sep 3, 2020
* fix: push '\' into className before regex special characters

* The `extractClassesFromHtml` function can fail to parse the some HTMLs because they have class names including special characters for regular expression.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants