Skip to content

Commit

Permalink
quote $ and \ to not confuse the Matcher.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbien committed Aug 8, 2021
1 parent 4a476e6 commit f90f714
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public String render(WeblogEntry entry, String str) {

// we only have to encode the opening angle bracket for valid html/xhtml
private static String encode(String code_inner) {
return code_inner.replace("<", LT);
return Matcher.quoteReplacement(code_inner.replace("<", LT)); // matchers hate $ and \
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ public void substitution2() {
" </head>\n" +
" <body>\n" +
" <pre><code class='language-java'>private final Map<String, List<?>> map = new HashMap<>();</code></pre>\n"+
" <pre><code class='language-bash'>$JDK/bin/java -version</code></pre>\n"+
" <pre><code class='language-slash'>\\\\</code></pre>\n"+
" </body>\n" +
"</html>";

Expand All @@ -94,6 +96,8 @@ public void substitution2() {
" </head>\n" +
" <body>\n" +
" <pre><code class='language-java'>private final Map&lt;String, List&lt;?>> map = new HashMap&lt;>();</code></pre>\n"+
" <pre><code class='language-bash'>$JDK/bin/java -version</code></pre>\n"+
" <pre><code class='language-slash'>\\\\</code></pre>\n"+
" </body>\n" +
"</html>";
assertEquals(expected, instance.render(null, input));
Expand Down

0 comments on commit f90f714

Please sign in to comment.