1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
# frozen_string_literal: true
require "helper"
module Nokogiri
module HTML
class TestAttributesProperlyEscaped < Nokogiri::TestCase
def test_attribute_macros_are_escaped
skip_unless_libxml2_patch("0001-Remove-script-macro-support.patch") if Nokogiri.uses_libxml?
html = "<p><i for=\"&{<test>}\"></i></p>"
document = Nokogiri::HTML::Document.new
nodes = document.parse(html)
assert_equal("<p><i for=\"&{<test>}\"></i></p>", nodes[0].to_s)
end
def test_libxml_escapes_server_side_includes
skip_unless_libxml2_patch("0002-Update-entities-to-remove-handling-of-ssi.patch") if Nokogiri.uses_libxml?
original_html = %(<p><a href='<!--"><test>-->'></a></p>)
document = Nokogiri::HTML::Document.new
html = document.parse(original_html).to_s
assert_match(/!--%22><test>/, html)
end
def test_libxml_escapes_server_side_includes_without_nested_quotes
skip_unless_libxml2_patch("0002-Update-entities-to-remove-handling-of-ssi.patch") if Nokogiri.uses_libxml?
original_html = %(<p><i for="<!--<test>-->"></i></p>)
document = Nokogiri::HTML::Document.new
html = document.parse(original_html).to_s
assert_match(/<!--<test>/, html)
end
end
end
end
|