aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-docs/src/templates
diff options
context:
space:
mode:
authorWouter Admiraal <wouter.admiraal@sonarsource.com>2019-05-21 08:34:52 +0200
committerSonarTech <sonartech@sonarsource.com>2019-05-27 20:21:09 +0200
commita815f59e579ff2eef9e31fb6ca981d436072b220 (patch)
treed42d1c5b1cd13b8d1c4968c5c1dc26bbf702eb25 /server/sonar-docs/src/templates
parent7456816f75260ca484ef6b0474e01a4a6de27621 (diff)
downloadsonarqube-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.tsx5
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);