diff --git a/.travis.yml b/.travis.yml index 3e0b723..9b992ac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,8 @@ rvm: - 2.4 - 2.5 - 2.6 + - 2.7 + - 3.0 - ruby-head - jruby matrix: diff --git a/CHANGELOG.md b/CHANGELOG.md index 9af8242..7fa6422 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,15 @@ +## next / unreleased + +* Processing Instructions are no longer allowed by Rails::Html::PermitScrubber + + Previously, a PI with a name (or "target") matching an allowed tag name was not scrubbed. There + are no known security issues associated with these PIs, but similar to comments it's preferred to + omit these nodes when possible from sanitized output. + + Fixes #115. + + *Mike Dalessio* + ## 1.3.0 * Address deprecations in Loofah 2.3.0. diff --git a/lib/rails/html/scrubbers.rb b/lib/rails/html/scrubbers.rb index c44d0ee..ad27971 100644 --- a/lib/rails/html/scrubbers.rb +++ b/lib/rails/html/scrubbers.rb @@ -68,7 +68,7 @@ def scrub(node) end return CONTINUE if skip_node?(node) - unless keep_node?(node) + unless node.element? && keep_node?(node) return STOP if scrub_node(node) == STOP end diff --git a/test/sanitizer_test.rb b/test/sanitizer_test.rb index f3624e7..7938433 100644 --- a/test/sanitizer_test.rb +++ b/test/sanitizer_test.rb @@ -521,6 +521,14 @@ def test_uri_escaping_of_name_action_in_a_tag_in_safe_list_sanitizer assert_equal %{test}, text end + def test_exclude_node_type_processing_instructions + assert_equal("
text
text", safe_list_sanitize("
text
text")) + end + + def test_exclude_node_type_comment + assert_equal("
text
text", safe_list_sanitize("
text
text")) + end + protected def xpath_sanitize(input, options = {})