Skip to content

Escape method names in HTML #762

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/rdoc/markup/to_html_crossref.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def link name, text, code = true
path = ref.as_href @from_path

if code and RDoc::CodeObject === ref and !(RDoc::TopLevel === ref)
text = "<code>#{text}</code>"
text = "<code>#{CGI.escapeHTML text}</code>"
end

if path =~ /#/ then
Expand Down
14 changes: 14 additions & 0 deletions test/rdoc/test_rdoc_markup_to_html_crossref.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,20 @@ def test_convert_RDOCLINK_rdoc_ref_method_percent
assert_equal para("<a href=\"C1.html#method-c-25\"><code>C1::%</code></a>"), result
end

def test_convert_RDOCLINK_rdoc_ref_method_escape_html
m = @c1.add_method RDoc::AnyMethod.new nil, '<<'
m.singleton = false

result = @to.convert 'rdoc-ref:C1#<<'

assert_equal para("<a href=\"C1.html#method-i-3C-3C\"><code>C1#&lt;&lt;</code></a>"), result
m.singleton = true

result = @to.convert 'rdoc-ref:C1::<<'

assert_equal para("<a href=\"C1.html#method-c-3C-3C\"><code>C1::&lt;&lt;</code></a>"), result
end

def test_convert_RDOCLINK_rdoc_ref_method_percent_label
m = @c1.add_method RDoc::AnyMethod.new nil, '%'
m.singleton = false
Expand Down