Compare commits

..

10 Commits

Author SHA1 Message Date
openeuler-ci-bot
cb1e3a4671
!13 [sync] PR-12: Upgrade to 1.4.3
From: @openeuler-sync-bot 
Reviewed-by: @jxy_git 
Signed-off-by: @jxy_git
2023-08-14 07:39:47 +00:00
jxy_git
67638b6195 Upgrade to 1.4.3
(cherry picked from commit 219143a6ce95f6e0db61c2448614133f8efeb61a)
2023-08-14 15:34:21 +08:00
openeuler-ci-bot
43a9203377
!10 Fix build error in openEuler-Mainline
From: @bzg1107 
Reviewed-by: @jxy_git 
Signed-off-by: @jxy_git
2022-07-14 07:52:28 +00:00
baizg1107
0212715d5d fix test failures 2022-07-14 15:33:28 +08:00
openeuler-ci-bot
c19f316b49
!7 fix changelog error
From: @dou33 
Reviewed-by: @jxy_git 
Signed-off-by: @jxy_git
2022-06-08 08:38:16 +00:00
dou33
7b47c9faa8 fix changelog error 2022-06-08 14:37:44 +08:00
openeuler-ci-bot
ecaef7b5dc
!6 [sync] PR-4: Upgrade to 1.4.2
From: @openeuler-sync-bot 
Reviewed-by: @small_leek 
Signed-off-by: @small_leek
2022-03-31 01:30:54 +00:00
wangkerong
0c57779f23 Upgrade to 1.4.2
(cherry picked from commit 6bbc8a9932207a517240f06e0b9c6a27b4296ea4)
2022-03-23 11:27:49 +08:00
openeuler-ci-bot
082fa117bd !1 init rubygem-rails-html-sanitizer package
Merge pull request !1 from PokeHuang/master
2020-08-27 10:07:57 +08:00
PokeHuang
67f2ea675a init rubygem-rails-html-sanitizer package 2020-08-25 11:58:12 +08:00
4 changed files with 164 additions and 0 deletions

Binary file not shown.

View File

@ -0,0 +1,85 @@
From 307ecf22162f58af85d7b4fe571e3d5b8bdf44c7 Mon Sep 17 00:00:00 2001
From: Mike Dalessio <mike.dalessio@gmail.com>
Date: Wed, 17 Aug 2022 10:54:37 -0400
Subject: [PATCH] tests: handle libxml 2.10.0 incorrectly-opened comment
parsing
Related, see:
- https://github.com/sparklemotion/nokogiri/pull/2625
- https://gitlab.gnome.org/GNOME/libxml2/-/issues/380
---
test/sanitizer_test.rb | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/test/sanitizer_test.rb b/test/sanitizer_test.rb
index e3ce218..e83c54d 100644
--- a/test/sanitizer_test.rb
+++ b/test/sanitizer_test.rb
@@ -54,7 +54,7 @@ def test_remove_xpaths_called_with_enumerable_xpaths
def test_strip_tags_with_quote
input = '<" <img src="trollface.gif" onload="alert(1)"> hi'
- expected = libxml_2_9_14_recovery? ? %{&lt;" hi} : %{ hi}
+ expected = libxml_2_9_14_recovery_lt? ? %{&lt;" hi} : %{ hi}
assert_equal(expected, full_sanitize(input))
end
@@ -77,19 +77,19 @@ def test_strip_tags_multiline
def test_remove_unclosed_tags
input = "This is <-- not\n a comment here."
- expected = libxml_2_9_14_recovery? ? %{This is &lt;-- not\n a comment here.} : %{This is }
+ expected = libxml_2_9_14_recovery_lt? ? %{This is &lt;-- not\n a comment here.} : %{This is }
assert_equal(expected, full_sanitize(input))
end
def test_strip_cdata
input = "This has a <![CDATA[<section>]]> here."
- expected = libxml_2_9_14_recovery? ? %{This has a &lt;![CDATA[]]&gt; here.} : %{This has a ]]&gt; here.}
+ expected = libxml_2_9_14_recovery_lt_bang? ? %{This has a &lt;![CDATA[]]&gt; here.} : %{This has a ]]&gt; here.}
assert_equal(expected, full_sanitize(input))
end
def test_strip_unclosed_cdata
input = "This has an unclosed <![CDATA[<section>]] here..."
- expected = libxml_2_9_14_recovery? ? %{This has an unclosed &lt;![CDATA[]] here...} : %{This has an unclosed ]] here...}
+ expected = libxml_2_9_14_recovery_lt_bang? ? %{This has an unclosed &lt;![CDATA[]] here...} : %{This has an unclosed ]] here...}
assert_equal(expected, full_sanitize(input))
end
@@ -464,13 +464,13 @@ def test_should_sanitize_img_vbscript
def test_should_sanitize_cdata_section
input = "<![CDATA[<span>section</span>]]>"
- expected = libxml_2_9_14_recovery? ? %{&lt;![CDATA[<span>section</span>]]&gt;} : %{section]]&gt;}
+ expected = libxml_2_9_14_recovery_lt_bang? ? %{&lt;![CDATA[<span>section</span>]]&gt;} : %{section]]&gt;}
assert_sanitized(input, expected)
end
def test_should_sanitize_unterminated_cdata_section
input = "<![CDATA[<span>neverending..."
- expected = libxml_2_9_14_recovery? ? %{&lt;![CDATA[<span>neverending...</span>} : %{neverending...}
+ expected = libxml_2_9_14_recovery_lt_bang? ? %{&lt;![CDATA[<span>neverending...</span>} : %{neverending...}
assert_sanitized(input, expected)
end
@@ -663,10 +663,17 @@ def convert_to_css_hex(string, escape_parens=false)
end.join
end
- def libxml_2_9_14_recovery?
+ def libxml_2_9_14_recovery_lt?
+ # changed in 2.9.14, see https://github.com/sparklemotion/nokogiri/releases/tag/v1.13.5
Nokogiri.method(:uses_libxml?).arity == -1 && Nokogiri.uses_libxml?(">= 2.9.14")
end
+ def libxml_2_9_14_recovery_lt_bang?
+ # changed in 2.9.14, see https://github.com/sparklemotion/nokogiri/releases/tag/v1.13.5
+ # then reverted in 2.10.0, see https://gitlab.gnome.org/GNOME/libxml2/-/issues/380
+ Nokogiri.method(:uses_libxml?).arity == -1 && Nokogiri.uses_libxml?("= 2.9.14")
+ end
+
def html5_mode?
::Loofah.respond_to?(:html5_mode?) && ::Loofah.html5_mode?
end

View File

@ -0,0 +1,75 @@
%global gem_name rails-html-sanitizer
Name: rubygem-%{gem_name}
Version: 1.4.3
Release: 1
Summary: This gem is responsible to sanitize HTML fragments in Rails applications
License: MIT
URL: https://github.com/rails/rails-html-sanitizer
Source0: https://rubygems.org/gems/%{gem_name}-%{version}.gem
# https://github.com/rails/rails-html-sanitizer/pull/143
# libxml2 2.10.x changes incorrectly opened comments parsing
Patch0: %{name}-1.4.3-tests-libxml2-2_10_0-parsing-comments-change.patch
BuildRequires: ruby(release)
BuildRequires: rubygems-devel
BuildRequires: ruby
BuildRequires: rubygem(loofah)
BuildRequires: rubygem(minitest)
BuildRequires: rubygem(rails-dom-testing)
BuildArch: noarch
%description
HTML sanitization for Rails applications.
%package doc
Summary: Documentation for %{name}
Requires: %{name} = %{version}-%{release}
BuildArch: noarch
%description doc
Documentation for %{name}.
%prep
%setup -q -n %{gem_name}-%{version}
%patch0 -p1
%build
gem build ../%{gem_name}-%{version}.gemspec
%gem_install
%install
mkdir -p %{buildroot}%{gem_dir}
cp -a .%{gem_dir}/* \
%{buildroot}%{gem_dir}/
%check
pushd .%{gem_instdir}
ruby -Ilib -e 'Dir.glob "./test/**/*_test.rb", &method(:require)'
popd
%files
%dir %{gem_instdir}
%license %{gem_instdir}/MIT-LICENSE
%{gem_libdir}
%exclude %{gem_cache}
%{gem_spec}
%files doc
%doc %{gem_docdir}
%doc %{gem_instdir}/CHANGELOG.md
%doc %{gem_instdir}/README.md
%{gem_instdir}/test
%changelog
* Mon Aug 14 2023 liqiuyu <liqiuyu@kylinos.cn> - 1.4.3-1
- Upgrade to 1.4.3
* Thu Jul 14 2022 baizhonggui <baizhonggui@h-partners.com> - 1.4.2-2
- Fix test failures
* Wed May 4 2022 wangkerong <wangkerong@h-partners.com> - 1.4.2-1
- Upgrade to 1.4.2
* Tue Aug 25 2020 huangyangke <huangyangke@huawei.com> - 1.0.4-1
- package init

View File

@ -0,0 +1,4 @@
version_control: github
src_repo: rails/rails-html-sanitizer
tag_prefix: "^v"
separator: "."