diff --git a/.idea/.idea.Html2Markdown/.idea/sonarlint.xml b/.idea/.idea.Html2Markdown/.idea/sonarlint.xml new file mode 100644 index 00000000..f0b33da7 --- /dev/null +++ b/.idea/.idea.Html2Markdown/.idea/sonarlint.xml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/.idea/.idea.Html2Markdown/.idea/sonarlint/issuestore/6/7/67b930d18dec91a33af163b768de668916419abe b/.idea/.idea.Html2Markdown/.idea/sonarlint/issuestore/6/7/67b930d18dec91a33af163b768de668916419abe new file mode 100644 index 00000000..e69de29b diff --git a/.idea/.idea.Html2Markdown/.idea/sonarlint/issuestore/7/4/74fc7b790e5b95a61f3f2942ea2a8eec781a2be0 b/.idea/.idea.Html2Markdown/.idea/sonarlint/issuestore/7/4/74fc7b790e5b95a61f3f2942ea2a8eec781a2be0 new file mode 100644 index 00000000..e69de29b diff --git a/.idea/.idea.Html2Markdown/.idea/sonarlint/issuestore/index.pb b/.idea/.idea.Html2Markdown/.idea/sonarlint/issuestore/index.pb new file mode 100644 index 00000000..2bef50e4 --- /dev/null +++ b/.idea/.idea.Html2Markdown/.idea/sonarlint/issuestore/index.pb @@ -0,0 +1,5 @@ + +[ ++src/Html2Markdown/Replacement/HtmlParser.cs,6\7\67b930d18dec91a33af163b768de668916419abe +` +0src/Html2Markdown/Replacement/PatternReplacer.cs,7\4\74fc7b790e5b95a61f3f2942ea2a8eec781a2be0 \ No newline at end of file diff --git a/.idea/.idea.Html2Markdown/.idea/sonarlint/securityhotspotstore/6/7/67b930d18dec91a33af163b768de668916419abe b/.idea/.idea.Html2Markdown/.idea/sonarlint/securityhotspotstore/6/7/67b930d18dec91a33af163b768de668916419abe new file mode 100644 index 00000000..e69de29b diff --git a/.idea/.idea.Html2Markdown/.idea/sonarlint/securityhotspotstore/7/4/74fc7b790e5b95a61f3f2942ea2a8eec781a2be0 b/.idea/.idea.Html2Markdown/.idea/sonarlint/securityhotspotstore/7/4/74fc7b790e5b95a61f3f2942ea2a8eec781a2be0 new file mode 100644 index 00000000..e69de29b diff --git a/.idea/.idea.Html2Markdown/.idea/sonarlint/securityhotspotstore/index.pb b/.idea/.idea.Html2Markdown/.idea/sonarlint/securityhotspotstore/index.pb new file mode 100644 index 00000000..2bef50e4 --- /dev/null +++ b/.idea/.idea.Html2Markdown/.idea/sonarlint/securityhotspotstore/index.pb @@ -0,0 +1,5 @@ + +[ ++src/Html2Markdown/Replacement/HtmlParser.cs,6\7\67b930d18dec91a33af163b768de668916419abe +` +0src/Html2Markdown/Replacement/PatternReplacer.cs,7\4\74fc7b790e5b95a61f3f2942ea2a8eec781a2be0 \ No newline at end of file diff --git a/src/Html2Markdown/Replacement/HtmlParser.cs b/src/Html2Markdown/Replacement/HtmlParser.cs index 93b1f45a..0406335a 100644 --- a/src/Html2Markdown/Replacement/HtmlParser.cs +++ b/src/Html2Markdown/Replacement/HtmlParser.cs @@ -221,9 +221,11 @@ private static string GetSyntaxHighlightLanguage(HtmlNode node) return string.Empty; } - return classAttributeValue.StartsWith("lang") - ? classAttributeValue.Split('-').Last() - : classAttributeValue; + if (!classAttributeValue.StartsWith("lang")) return classAttributeValue; + var split = classAttributeValue.Split('-'); + + return split[^1]; // PERFORMANCE: https://sonarcloud.io/organizations/baynezy/rules?open=csharpsquid%3AS6608&rule_key=csharpsquid%3AS6608 + } internal static string ReplaceBlockquote(string html) diff --git a/src/Html2Markdown/Replacement/PatternReplacer.cs b/src/Html2Markdown/Replacement/PatternReplacer.cs index 0c6e7052..e414b3c5 100644 --- a/src/Html2Markdown/Replacement/PatternReplacer.cs +++ b/src/Html2Markdown/Replacement/PatternReplacer.cs @@ -11,7 +11,8 @@ public class PatternReplacer : IReplacer public string Replacement { get; init; } public string Replace(string html) { - var regex = new Regex(Pattern); + // SECURITY: https://sonarcloud.io/organizations/baynezy/rules?open=csharpsquid%3AS6444&rule_key=csharpsquid%3AS6444 + var regex = new Regex(Pattern, RegexOptions.None, TimeSpan.FromSeconds(1)); return regex.Replace(html, Replacement); }