[ruby/rdoc] Escape file names
https://hackerone.com/reports/1321358 https://github.com/ruby/rdoc/commit/8c07cc4657
This commit is contained in:
parent
8d0b2162a0
commit
a3cb09c7d1
@ -12,18 +12,18 @@
|
|||||||
<%- end.each do |n, files| -%>
|
<%- end.each do |n, files| -%>
|
||||||
<%- f = files.shift -%>
|
<%- f = files.shift -%>
|
||||||
<%- if files.empty? -%>
|
<%- if files.empty? -%>
|
||||||
<li><a href="<%= rel_prefix %>/<%= f.path %>"><%= h f.page_name %></a>
|
<li><a href="<%= rel_prefix %>/<%= h f.path %>"><%= h f.page_name %></a>
|
||||||
<%- next -%>
|
<%- next -%>
|
||||||
<%- end -%>
|
<%- end -%>
|
||||||
<li><details<% if dir == n %> open<% end %>><summary><%
|
<li><details<% if dir == n %> open<% end %>><summary><%
|
||||||
if n == f.page_name
|
if n == f.page_name
|
||||||
%><a href="<%= rel_prefix %>/<%= f.path %>"><%= h n %></a><%
|
%><a href="<%= rel_prefix %>/<%= h f.path %>"><%= h n %></a><%
|
||||||
else
|
else
|
||||||
%><%= h n %><% files.unshift(f)
|
%><%= h n %><% files.unshift(f)
|
||||||
end %></summary>
|
end %></summary>
|
||||||
<ul class="link-list">
|
<ul class="link-list">
|
||||||
<%- files.each do |f| -%>
|
<%- files.each do |f| -%>
|
||||||
<li><a href="<%= rel_prefix %>/<%= f.path %>"><%= h f.page_name %></a>
|
<li><a href="<%= rel_prefix %>/<%= h f.path %>"><%= h f.page_name %></a>
|
||||||
<%- end -%>
|
<%- end -%>
|
||||||
</ul></details>
|
</ul></details>
|
||||||
<%- end -%>
|
<%- end -%>
|
||||||
|
@ -8,14 +8,14 @@
|
|||||||
<ul>
|
<ul>
|
||||||
<%- simple_files.sort.each do |file| -%>
|
<%- simple_files.sort.each do |file| -%>
|
||||||
<li class="file">
|
<li class="file">
|
||||||
<a href="<%= file.path %>"><%= h file.page_name %></a>
|
<a href="<%= h file.path %>"><%= h file.page_name %></a>
|
||||||
<%
|
<%
|
||||||
# HACK table_of_contents should not exist on Document
|
# HACK table_of_contents should not exist on Document
|
||||||
table = file.parse(file.comment).table_of_contents
|
table = file.parse(file.comment).table_of_contents
|
||||||
unless table.empty? then %>
|
unless table.empty? then %>
|
||||||
<ul>
|
<ul>
|
||||||
<%- table.each do |heading| -%>
|
<%- table.each do |heading| -%>
|
||||||
<li><a href="<%= file.path %>#<%= heading.aref %>"><%= heading.plain_html %></a>
|
<li><a href="<%= h file.path %>#<%= heading.aref %>"><%= heading.plain_html %></a>
|
||||||
<%- end -%>
|
<%- end -%>
|
||||||
</ul>
|
</ul>
|
||||||
<%- end -%>
|
<%- end -%>
|
||||||
|
@ -233,6 +233,20 @@ class TestRDocGeneratorDarkfish < RDoc::TestCase
|
|||||||
assert_includes method_name, '{ |%<<script>alert("atui")</script>>, yield_arg| ... }'
|
assert_includes method_name, '{ |%<<script>alert("atui")</script>>, yield_arg| ... }'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_generated_filename_with_html_tag
|
||||||
|
@store.add_file '"><em>should be escaped'
|
||||||
|
doc = @store.all_files.last
|
||||||
|
doc.parser = RDoc::Parser::Simple
|
||||||
|
|
||||||
|
@g.generate
|
||||||
|
|
||||||
|
Dir.glob("*.html", base: @tmpdir) do |html|
|
||||||
|
File.read(File.join(@tmpdir, html)).scan(/.*should be escaped.*/) do |line|
|
||||||
|
assert_not_include line, "<em>", html
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_template_stylesheets
|
def test_template_stylesheets
|
||||||
css = Tempfile.create(%W'hoge .css', Dir.mktmpdir('tmp', '.'))
|
css = Tempfile.create(%W'hoge .css', Dir.mktmpdir('tmp', '.'))
|
||||||
File.write(css, '')
|
File.write(css, '')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user