From 92d9a238d784d13120ea13a5717434a11045eac9 Mon Sep 17 00:00:00 2001 From: cherry530 Date: Thu, 10 Feb 2022 09:51:22 +0800 Subject: [PATCH] Fix ParseTreeVisitor error and DropsTest failure Signed-off-by: cherry530 (cherry picked from commit aaab371e6ae29ed833e416b785584031edf833f0) --- ...n-drop_test-disable-tests-broken-wit.patch | 40 +++++++++++++++++++ ...arse-tree-visitor-test-for-ruby-head.patch | 22 ++++++++++ rubygem-liquid.spec | 9 ++++- 3 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 03-tests-integration-drop_test-disable-tests-broken-wit.patch create mode 100644 04-fix-parse-tree-visitor-test-for-ruby-head.patch diff --git a/03-tests-integration-drop_test-disable-tests-broken-wit.patch b/03-tests-integration-drop_test-disable-tests-broken-wit.patch new file mode 100644 index 0000000..4f627de --- /dev/null +++ b/03-tests-integration-drop_test-disable-tests-broken-wit.patch @@ -0,0 +1,40 @@ +From 48ed7aa9c516aa9ddef53fed0ffcd6705f814a23 Mon Sep 17 00:00:00 2001 +From: Fabio Valentini +Date: Fri, 31 Jan 2020 17:29:49 +0100 +Subject: [PATCH 2/2] tests/integration/drop_test: disable tests broken with + ruby 2.7 + +--- + test/integration/drop_test.rb | 36 +++++++++++++++++------------------ + 1 file changed, 18 insertions(+), 18 deletions(-) + +diff --git a/test/integration/drop_test.rb b/test/integration/drop_test.rb +index 2de4a5a..a1abca0 100644 +--- a/test/integration/drop_test.rb ++++ b/test/integration/drop_test.rb +@@ -112,25 +112,6 @@ class DropsTest < Minitest::Test + assert_equal ' ', tpl.render!('product' => ProductDrop.new) + end + +- def test_rendering_raises_on_tainted_attr +- with_taint_mode(:error) do +- tpl = Liquid::Template.parse('{{ product.user_input }}') +- assert_raises TaintedError do +- tpl.render!('product' => ProductDrop.new) +- end +- end +- end +- +- def test_rendering_warns_on_tainted_attr +- with_taint_mode(:warn) do +- tpl = Liquid::Template.parse('{{ product.user_input }}') +- context = Context.new('product' => ProductDrop.new) +- tpl.render!(context) +- assert_equal [Liquid::TaintedError], context.warnings.map(&:class) +- assert_equal "variable 'product.user_input' is tainted and was not escaped", context.warnings.first.to_s(false) +- end +- end +- + def test_rendering_doesnt_raise_on_escaped_tainted_attr + with_taint_mode(:error) do + tpl = Liquid::Template.parse('{{ product.user_input | escape }}') diff --git a/04-fix-parse-tree-visitor-test-for-ruby-head.patch b/04-fix-parse-tree-visitor-test-for-ruby-head.patch new file mode 100644 index 0000000..853e7f0 --- /dev/null +++ b/04-fix-parse-tree-visitor-test-for-ruby-head.patch @@ -0,0 +1,22 @@ +From 81149344a5ba53b30e8ab7d77d605dc484a0a3ff Mon Sep 17 00:00:00 2001 +From: Dylan Thacker-Smith +Date: Tue, 31 Mar 2020 10:19:25 -0400 +Subject: [PATCH] Fix ParseTreeVisitorTest for ruby-head + +--- + test/integration/parse_tree_visitor_test.rb | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/test/integration/parse_tree_visitor_test.rb b/test/integration/parse_tree_visitor_test.rb +index 6ad6a2d..933dbc3 100644 +--- a/test/integration/parse_tree_visitor_test.rb ++++ b/test/integration/parse_tree_visitor_test.rb +@@ -238,7 +238,7 @@ class ParseTreeVisitorTest < Minitest::Test + def traversal(template) + ParseTreeVisitor + .for(Template.parse(template).root) +- .add_callback_for(VariableLookup, &:name) ++ .add_callback_for(VariableLookup) { |node| node.name } # rubocop:disable Style/SymbolProc + end + + def visit(template) diff --git a/rubygem-liquid.spec b/rubygem-liquid.spec index 21b5b5a..fedef2c 100644 --- a/rubygem-liquid.spec +++ b/rubygem-liquid.spec @@ -2,12 +2,14 @@ Name: rubygem-%{gem_name} Summary: Secure, non-evaling end user template engine Version: 4.0.3 -Release: 1 +Release: 2 License: MIT URL: http://www.liquidmarkup.org Source0: https://rubygems.org/gems/%{gem_name}-%{version}.gem Patch1: 01-test-unit-context-disable-stack-profiler.patch Patch2: 02-test-helper-remove-shebang-and-executable-bit.patch +Patch3: 03-tests-integration-drop_test-disable-tests-broken-wit.patch +Patch4: 04-fix-parse-tree-visitor-test-for-ruby-head.patch BuildArch: noarch BuildRequires: ruby(release) ruby >= 2.1.0 rubygems-devel >= 1.3.7 BuildRequires: rubygem(bigdecimal) rubygem(minitest) @@ -34,6 +36,8 @@ Documentation for %{name}. %setup -q -n %{gem_name}-%{version} %patch1 -p1 %patch2 -p1 +%patch3 -p1 +%patch4 -p1 %build gem build ../%{gem_name}-%{version}.gemspec @@ -62,5 +66,8 @@ popd %{gem_instdir}/test %changelog +* Thu Feb 10 2022 xu_ping - 4.0.3-2 +- Fix ParseTreeVisitor error and DropsTest failure + * Thu Jul 30 2020 wutao - 4.0.3-1 - package init