Skip to content

ci: add coverage for system libxml2 #126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,22 @@ jobs:
bundler-cache: true
- run: bundle exec rake

cruby-nokogiri-system-libraries:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.1"
- name: Install nokogiri with system libraries
run: |
sudo apt install pkg-config libxml2-dev libxslt-dev
bundle config set force_ruby_platform true
bundle config build.nokogiri --enable-system-libraries
bundle install
bundle exec nokogiri -v
- run: bundle exec rake

jruby:
continue-on-error: true # nokogiri on jruby has different behavior
strategy:
Expand Down
32 changes: 28 additions & 4 deletions test/sanitizer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,13 @@ def test_uri_escaping_of_href_attr_in_a_tag_in_safe_list_sanitizer

text = safe_list_sanitize(html)

assert_equal %{<a href=\"examp&lt;!--%22%20unsafeattr=foo()&gt;--&gt;le.com\">test</a>}, text
acceptable_results = [
# nokogiri w/vendored+patched libxml2
%{<a href="examp&lt;!--%22%20unsafeattr=foo()&gt;--&gt;le.com">test</a>},
# nokogiri w/ system libxml2
%{<a href="examp<!--%22%20unsafeattr=foo()>-->le.com">test</a>},
]
assert_includes(acceptable_results, text)
end

def test_uri_escaping_of_src_attr_in_a_tag_in_safe_list_sanitizer
Expand All @@ -515,7 +521,13 @@ def test_uri_escaping_of_src_attr_in_a_tag_in_safe_list_sanitizer

text = safe_list_sanitize(html)

assert_equal %{<a src=\"examp&lt;!--%22%20unsafeattr=foo()&gt;--&gt;le.com\">test</a>}, text
acceptable_results = [
# nokogiri w/vendored+patched libxml2
%{<a src="examp&lt;!--%22%20unsafeattr=foo()&gt;--&gt;le.com">test</a>},
# nokogiri w/system libxml2
%{<a src="examp<!--%22%20unsafeattr=foo()>-->le.com">test</a>},
]
assert_includes(acceptable_results, text)
end

def test_uri_escaping_of_name_attr_in_a_tag_in_safe_list_sanitizer
Expand All @@ -525,7 +537,13 @@ def test_uri_escaping_of_name_attr_in_a_tag_in_safe_list_sanitizer

text = safe_list_sanitize(html)

assert_equal %{<a name=\"examp&lt;!--%22%20unsafeattr=foo()&gt;--&gt;le.com\">test</a>}, text
acceptable_results = [
# nokogiri w/vendored+patched libxml2
%{<a name="examp&lt;!--%22%20unsafeattr=foo()&gt;--&gt;le.com">test</a>},
# nokogiri w/system libxml2
%{<a name="examp<!--%22%20unsafeattr=foo()>-->le.com">test</a>},
]
assert_includes(acceptable_results, text)
end

def test_uri_escaping_of_name_action_in_a_tag_in_safe_list_sanitizer
Expand All @@ -535,7 +553,13 @@ def test_uri_escaping_of_name_action_in_a_tag_in_safe_list_sanitizer

text = safe_list_sanitize(html, attributes: ['action'])

assert_equal %{<a action=\"examp&lt;!--%22%20unsafeattr=foo()&gt;--&gt;le.com\">test</a>}, text
acceptable_results = [
# nokogiri w/vendored+patched libxml2
%{<a action="examp&lt;!--%22%20unsafeattr=foo()&gt;--&gt;le.com">test</a>},
# nokogiri w/system libxml2
%{<a action="examp<!--%22%20unsafeattr=foo()>-->le.com">test</a>},
]
assert_includes(acceptable_results, text)
end

def test_exclude_node_type_processing_instructions
Expand Down