Fix #602
This commit is contained in:
@@ -6,6 +6,7 @@ module Precious
|
|||||||
attr_reader :content, :page, :header, :footer
|
attr_reader :content, :page, :header, :footer
|
||||||
DATE_FORMAT = "%Y-%m-%d %H:%M:%S"
|
DATE_FORMAT = "%Y-%m-%d %H:%M:%S"
|
||||||
DEFAULT_AUTHOR = 'you'
|
DEFAULT_AUTHOR = 'you'
|
||||||
|
@@to_xml = { :save_with => Nokogiri::XML::Node::SaveOptions::DEFAULT_XHTML ^ 1, :indent => 0, :encoding => 'UTF-8' }
|
||||||
|
|
||||||
def title
|
def title
|
||||||
h1 = @h1_title ? page_header_from_content(@content) : false
|
h1 = @h1_title ? page_header_from_content(@content) : false
|
||||||
@@ -134,7 +135,7 @@ module Precious
|
|||||||
def page_header_from_content(content)
|
def page_header_from_content(content)
|
||||||
doc = build_document(content)
|
doc = build_document(content)
|
||||||
title = find_header_node(doc)
|
title = find_header_node(doc)
|
||||||
Sanitize.clean(title.to_xhtml(:encoding => 'UTF-8')).strip unless title.empty?
|
Sanitize.clean(title.to_xml( @@to_xml )).strip unless title.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns page content without title if it was extracted.
|
# Returns page content without title if it was extracted.
|
||||||
@@ -144,7 +145,7 @@ module Precious
|
|||||||
title = find_header_node(doc)
|
title = find_header_node(doc)
|
||||||
title.remove unless title.empty?
|
title.remove unless title.empty?
|
||||||
# .inner_html will cause href escaping on UTF-8
|
# .inner_html will cause href escaping on UTF-8
|
||||||
doc.css("div#gollum-root").children.to_xhtml(:encoding => 'UTF-8')
|
doc.css("div#gollum-root").children.to_xml( @@to_xml )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+5
-2
@@ -42,7 +42,7 @@ context "Frontend" do
|
|||||||
assert_equal 'μ†ℱ'.scan(/./), ["μ", "†", "ℱ"]
|
assert_equal 'μ†ℱ'.scan(/./), ["μ", "†", "ℱ"]
|
||||||
end
|
end
|
||||||
|
|
||||||
# This should not match
|
|
||||||
test "broken four space" do
|
test "broken four space" do
|
||||||
page = 'utfh1'
|
page = 'utfh1'
|
||||||
text = %(
|
text = %(
|
||||||
@@ -56,8 +56,11 @@ context "Frontend" do
|
|||||||
{ :name => 'user1', :email => 'user1' });
|
{ :name => 'user1', :email => 'user1' });
|
||||||
|
|
||||||
get page
|
get page
|
||||||
|
# good html:
|
||||||
|
# <pre><code>one\ntwo\nthree\nfour\n</code></pre>\n
|
||||||
|
# broken html:
|
||||||
# <pre>\n <code>one\ntwo\nthree\nfour\n</code>\n</pre>
|
# <pre>\n <code>one\ntwo\nthree\nfour\n</code>\n</pre>
|
||||||
assert_match /<pre>\n <code>.+<\/code>\n<\/pre>/m, last_response.body
|
assert_match /<pre><code>one\ntwo\nthree\nfour\n<\/code><\/pre>\n/m, last_response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
test "UTF-8 headers href preserved" do
|
test "UTF-8 headers href preserved" do
|
||||||
|
|||||||
Reference in New Issue
Block a user