Skip to content

Commit

Permalink
Fix SyntaxHighlighter::HTML to escape identifier values (#13212)
Browse files Browse the repository at this point in the history
  • Loading branch information
straight-shoota committed Mar 22, 2023
1 parent 31c17f7 commit 2c8e606
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion spec/std/crystal/syntax_highlighter/html_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe Crystal::SyntaxHighlighter::HTML do
== < <= > >= != =~ !~
& | ^ ~ ** >> << %
).each do |op|
it_highlights %(def #{op}), %(<span class="k">def</span> <span class="m">#{op}</span>)
it_highlights %(def #{op}), %(<span class="k">def</span> <span class="m">#{HTML.escape(op)}</span>)
end

it_highlights %(def //), %(<span class="k">def</span> <span class="m">/</span><span class="m">/</span>)
Expand Down
2 changes: 1 addition & 1 deletion src/crystal/syntax_highlighter/html.cr
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Crystal::SyntaxHighlighter::HTML < Crystal::SyntaxHighlighter
when .string?
span "s" { ::HTML.escape(value, @io) }
when .ident?
span "m", &.print value
span "m" { ::HTML.escape(value, @io) }
when .keyword?, .self?
span "k", &.print value
when .primitive_literal?
Expand Down

0 comments on commit 2c8e606

Please sign in to comment.