From 8c07cc4657772d076e994896d8f3618c7c25083f Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sat, 28 Aug 2021 17:41:47 +0900 Subject: [PATCH 1/3] Escape file names https://hackerone.com/reports/1321358 --- .../template/darkfish/_sidebar_pages.rhtml | 6 +++--- .../template/darkfish/table_of_contents.rhtml | 4 ++-- test/rdoc/test_rdoc_generator_darkfish.rb | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml b/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml index 0ed683ca14..3f68f0c0dc 100644 --- a/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +++ b/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml @@ -12,18 +12,18 @@ <%- end.each do |n, files| -%> <%- f = files.shift -%> <%- if files.empty? -%> -
  • <%= h f.page_name %> +
  • <%= h f.page_name %> <%- next -%> <%- end -%>
  • open<% end %>><% if n == f.page_name - %><%= h n %><% + %><%= h n %><% else %><%= h n %><% files.unshift(f) end %> <%- end -%> diff --git a/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml b/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml index 303d7016cc..941ff9d630 100644 --- a/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +++ b/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml @@ -8,14 +8,14 @@
      <%- simple_files.sort.each do |file| -%>
    • - <%= h file.page_name %> + <%= h file.page_name %> <% # HACK table_of_contents should not exist on Document table = file.parse(file.comment).table_of_contents unless table.empty? then %> <%- end -%> diff --git a/test/rdoc/test_rdoc_generator_darkfish.rb b/test/rdoc/test_rdoc_generator_darkfish.rb index ae3a4c5ebf..26397bb6cb 100644 --- a/test/rdoc/test_rdoc_generator_darkfish.rb +++ b/test/rdoc/test_rdoc_generator_darkfish.rb @@ -233,6 +233,20 @@ def test_generated_method_with_html_tag_yield assert_includes method_name, '{ |%<<script>alert("atui")</script>>, yield_arg| ... }' end + def test_generated_filename_with_html_tag + @store.add_file '">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, "", html + end + end + end + def test_template_stylesheets css = Tempfile.create(%W'hoge .css', Dir.mktmpdir('tmp', '.')) File.write(css, '') From 2ebf8fd51005f389ad9f906311e6266de8e96fec Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 7 Sep 2021 23:52:13 +0900 Subject: [PATCH 2/3] Escape search results https://hackerone.com/reports/1321358 --- .../generator/template/darkfish/_head.rhtml | 20 +++++++++---------- .../template/darkfish/js/darkfish.js | 2 +- .../generator/template/darkfish/js/search.js | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/rdoc/generator/template/darkfish/_head.rhtml b/lib/rdoc/generator/template/darkfish/_head.rhtml index 4f331245c3..d5aed3e9ef 100644 --- a/lib/rdoc/generator/template/darkfish/_head.rhtml +++ b/lib/rdoc/generator/template/darkfish/_head.rhtml @@ -3,18 +3,18 @@ <%= h @title %> - - - - - + + + + + - - + + <%- @options.template_stylesheets.each do |stylesheet| -%> - + <%- end -%> diff --git a/lib/rdoc/generator/template/darkfish/js/darkfish.js b/lib/rdoc/generator/template/darkfish/js/darkfish.js index 111bbf8eb9..d0c9467751 100644 --- a/lib/rdoc/generator/template/darkfish/js/darkfish.js +++ b/lib/rdoc/generator/template/darkfish/js/darkfish.js @@ -54,7 +54,7 @@ function hookSearch() { var html = ''; // TODO add relative path to