diff options
author | Wouter Admiraal <wouter.admiraal@sonarsource.com> | 2019-05-21 08:34:52 +0200 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2019-05-27 20:21:09 +0200 |
commit | a815f59e579ff2eef9e31fb6ca981d436072b220 (patch) | |
tree | d42d1c5b1cd13b8d1c4968c5c1dc26bbf702eb25 /server/sonar-docs/src/templates | |
parent | 7456816f75260ca484ef6b0474e01a4a6de27621 (diff) | |
download | sonarqube-a815f59e579ff2eef9e31fb6ca981d436072b220.tar.gz sonarqube-a815f59e579ff2eef9e31fb6ca981d436072b220.zip |
SONAR-12125 Escape special characters before constructing regex
Diffstat (limited to 'server/sonar-docs/src/templates')
-rw-r--r-- | server/sonar-docs/src/templates/page.tsx | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/server/sonar-docs/src/templates/page.tsx b/server/sonar-docs/src/templates/page.tsx index b468d39971c..e0239d2bf27 100644 --- a/server/sonar-docs/src/templates/page.tsx +++ b/server/sonar-docs/src/templates/page.tsx @@ -157,7 +157,10 @@ function removeExtraHeadings(content: string, headings: MarkdownHeading[]) { .filter(heading => !heading.value || !heading.value.match(/Table of content/i)) .filter(heading => { const regex = new RegExp( - `<!-- sonarcloud -->[\\s\\S]*<h2>${heading.value}<\\/h2>[\\s\\S]*<!-- /sonarcloud -->`, + `<!-- sonarcloud -->[\\s\\S]*<h2>${heading.value!.replace( + /[.*+?^${}()|[\]\\]/g, + '\\$&' + )}<\\/h2>[\\s\\S]*<!-- /sonarcloud -->`, 'gim' ); return !content.match(regex); |