}
end
breadcrumb << %{}
breadcrumb.join("\n")
@@ -269,6 +264,10 @@ module Precious
result << "\n\n"
end
+ def title
+ h1 = @h1_title ? page_header_from_content(@content) : false
+ h1 || @page.url_path_title # url_path_title is the metadata title if present, otherwise the filename-based title
+ end
end
end
end
diff --git a/test/test_overview_view.rb b/test/test_overview_view.rb
index a0956fef..4189ed4c 100644
--- a/test/test_overview_view.rb
+++ b/test/test_overview_view.rb
@@ -43,12 +43,22 @@ context "Precious::Views::Overview" do
@page.instance_variable_set("@base_url", "")
assert_equal "", @page.breadcrumb
end
-
- test 'guard against malicious filenames' do
- malicious_title = ''
- @page.instance_variable_set("@path", malicious_title)
+
+ test "breadcrumbs guard against malicious filenames" do
+ malicious_path = '' + "\n # 3", commit_details)
- page = @wiki.page(title)
-
- @view = Precious::Views::Page.new
- @view.instance_variable_set :@page, page
- @view.instance_variable_set :@content, page.formatted_data
- @view.instance_variable_set :@h1_title, false
-
- # Title is based on file name when h1_title is false.
- actual = @view.title
- assert_equal title, actual
- end
-
test "breadcrumbs" do
@wiki.write_page('subdir/BC Test 1', :markdown, 'Test', commit_details)
page = @wiki.page('subdir/BC Test 1')