Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package rubygem-liquid for openSUSE:Factory checked in at 2022-03-04 20:16:59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-liquid (Old) and /work/SRC/openSUSE:Factory/.rubygem-liquid.new.1958 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-liquid" Fri Mar 4 20:16:59 2022 rev:8 rq:959331 version:5.2.0 Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-liquid/rubygem-liquid.changes 2022-02-07 23:38:47.134159049 +0100 +++ /work/SRC/openSUSE:Factory/.rubygem-liquid.new.1958/rubygem-liquid.changes 2022-03-04 20:20:49.152685089 +0100 @@ -1,0 +2,18 @@ +Thu Mar 3 08:22:17 UTC 2022 - Stephan Kulow <[email protected]> + +updated to version 5.2.0 + see installed History.md + + ## 5.2.0 2021-03-01 + + ### Features + * Add `remove_last`, and `replace_last` filters (#1422) [Anders Hagbard] + * Eagerly cache global filters (#1524) [Jean Boussier] + + ### Fixes + * Fix some internal errors in filters from invalid input (#1476) [Dylan Thacker-Smith] + * Allow dash in filter kwarg name for consistency with Liquid::C (#1518) [CP Clermont] + + + +------------------------------------------------------------------- Old: ---- liquid-5.1.0.gem New: ---- liquid-5.2.0.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-liquid.spec ++++++ --- /var/tmp/diff_new_pack.N6iIry/_old 2022-03-04 20:20:49.656684689 +0100 +++ /var/tmp/diff_new_pack.N6iIry/_new 2022-03-04 20:20:49.660684686 +0100 @@ -24,7 +24,7 @@ # Name: rubygem-liquid -Version: 5.1.0 +Version: 5.2.0 Release: 0 %define mod_name liquid %define mod_full_name %{mod_name}-%{version} ++++++ liquid-5.1.0.gem -> liquid-5.2.0.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/History.md new/History.md --- old/History.md 2021-09-15 21:16:18.000000000 +0200 +++ new/History.md 2022-03-01 16:20:24.000000000 +0100 @@ -1,5 +1,16 @@ # Liquid Change Log +## 5.2.0 2021-03-01 + +### Features +* Add `remove_last`, and `replace_last` filters (#1422) [Anders Hagbard] +* Eagerly cache global filters (#1524) [Jean Boussier] + +### Fixes +* Fix some internal errors in filters from invalid input (#1476) [Dylan Thacker-Smith] +* Allow dash in filter kwarg name for consistency with Liquid::C (#1518) [CP Clermont] + + ## 5.1.0 / 2021-09-09 ### Features diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/README.md new/README.md --- old/README.md 2021-09-15 21:16:18.000000000 +0200 +++ new/README.md 2022-03-01 16:20:24.000000000 +0100 @@ -5,7 +5,7 @@ * [Contributing guidelines](CONTRIBUTING.md) * [Version history](History.md) -* [Liquid documentation from Shopify](http://docs.shopify.com/themes/liquid-basics) +* [Liquid documentation from Shopify](https://shopify.dev/api/liquid) * [Liquid Wiki at GitHub](https://github.com/Shopify/liquid/wiki) * [Website](http://liquidmarkup.org/) @@ -56,7 +56,7 @@ Setting the error mode of Liquid lets you specify how strictly you want your templates to be interpreted. Normally the parser is very lax and will accept almost anything without error. Unfortunately this can make -it very hard to debug and can lead to unexpected behaviour. +it very hard to debug and can lead to unexpected behaviour. Liquid also comes with a stricter parser that can be used when editing templates to give better error messages when templates are invalid. You can enable this new parser like this: Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/liquid/block_body.rb new/lib/liquid/block_body.rb --- old/lib/liquid/block_body.rb 2021-09-15 21:16:18.000000000 +0200 +++ new/lib/liquid/block_body.rb 2022-03-01 16:20:24.000000000 +0100 @@ -231,8 +231,8 @@ end def create_variable(token, parse_context) - token.scan(ContentOfVariable) do |content| - markup = content.first + if token =~ ContentOfVariable + markup = Regexp.last_match(1) return Variable.new(markup, parse_context) end BlockBody.raise_missing_variable_terminator(token, parse_context) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/liquid/expression.rb new/lib/liquid/expression.rb --- old/lib/liquid/expression.rb 2021-09-15 21:16:18.000000000 +0200 +++ new/lib/liquid/expression.rb 2022-03-01 16:20:24.000000000 +0100 @@ -10,21 +10,23 @@ 'empty' => '' }.freeze - SINGLE_QUOTED_STRING = /\A\s*'(.*)'\s*\z/m - DOUBLE_QUOTED_STRING = /\A\s*"(.*)"\s*\z/m - INTEGERS_REGEX = /\A\s*(-?\d+)\s*\z/ - FLOATS_REGEX = /\A\s*(-?\d[\d\.]+)\s*\z/ + INTEGERS_REGEX = /\A(-?\d+)\z/ + FLOATS_REGEX = /\A(-?\d[\d\.]+)\z/ # Use an atomic group (?>...) to avoid pathological backtracing from # malicious input as described in https://github.com/Shopify/liquid/issues/1357 - RANGES_REGEX = /\A\s*\(\s*(?>(\S+)\s*\.\.)\s*(\S+)\s*\)\s*\z/ + RANGES_REGEX = /\A\(\s*(?>(\S+)\s*\.\.)\s*(\S+)\s*\)\z/ def self.parse(markup) + return nil unless markup + + markup = markup.strip + if (markup.start_with?('"') && markup.end_with?('"')) || + (markup.start_with?("'") && markup.end_with?("'")) + return markup[1..-2] + end + case markup - when nil - nil - when SINGLE_QUOTED_STRING, DOUBLE_QUOTED_STRING - Regexp.last_match(1) when INTEGERS_REGEX Regexp.last_match(1).to_i when RANGES_REGEX @@ -32,7 +34,6 @@ when FLOATS_REGEX Regexp.last_match(1).to_f else - markup = markup.strip if LITERALS.key?(markup) LITERALS[markup] else diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/liquid/standardfilters.rb new/lib/liquid/standardfilters.rb --- old/lib/liquid/standardfilters.rb 2021-09-15 21:16:18.000000000 +0200 +++ new/lib/liquid/standardfilters.rb 2022-03-01 16:20:24.000000000 +0100 @@ -213,17 +213,23 @@ if ary.empty? [] - elsif ary.first.respond_to?(:[]) && target_value.nil? - begin - ary.select { |item| item[property] } + elsif target_value.nil? + ary.select do |item| + item[property] rescue TypeError raise_property_error(property) + rescue NoMethodError + return nil unless item.respond_to?(:[]) + raise end - elsif ary.first.respond_to?(:[]) - begin - ary.select { |item| item[property] == target_value } + else + ary.select do |item| + item[property] == target_value rescue TypeError raise_property_error(property) + rescue NoMethodError + return nil unless item.respond_to?(:[]) + raise end end end @@ -237,11 +243,14 @@ ary.uniq elsif ary.empty? # The next two cases assume a non-empty array. [] - elsif ary.first.respond_to?(:[]) - begin - ary.uniq { |a| a[property] } + else + ary.uniq do |item| + item[property] rescue TypeError raise_property_error(property) + rescue NoMethodError + return nil unless item.respond_to?(:[]) + raise end end end @@ -277,11 +286,14 @@ ary.compact elsif ary.empty? # The next two cases assume a non-empty array. [] - elsif ary.first.respond_to?(:[]) - begin - ary.reject { |a| a[property].nil? } + else + ary.reject do |item| + item[property].nil? rescue TypeError raise_property_error(property) + rescue NoMethodError + return nil unless item.respond_to?(:[]) + raise end end end @@ -296,14 +308,34 @@ input.to_s.sub(string.to_s, replacement.to_s) end + # Replace the last occurrences of a string with another + def replace_last(input, string, replacement) + input = input.to_s + string = string.to_s + replacement = replacement.to_s + + start_index = input.rindex(string) + + return input unless start_index + + output = input.dup + output[start_index, string.length] = replacement + output + end + # remove a substring def remove(input, string) - input.to_s.gsub(string.to_s, '') + replace(input, string, '') end # remove the first occurrences of a substring def remove_first(input, string) - input.to_s.sub(string.to_s, '') + replace_first(input, string, '') + end + + # remove the last occurences of a substring + def remove_last(input, string) + replace_last(input, string, '') end # add one string to another @@ -486,10 +518,16 @@ end def nil_safe_compare(a, b) - if !a.nil? && !b.nil? - a <=> b + result = a <=> b + + if result + result + elsif a.nil? + 1 + elsif b.nil? + -1 else - a.nil? ? 1 : -1 + raise Liquid::ArgumentError, "cannot sort values of incompatible types" end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/liquid/strainer_factory.rb new/lib/liquid/strainer_factory.rb --- old/lib/liquid/strainer_factory.rb 2021-09-15 21:16:18.000000000 +0200 +++ new/lib/liquid/strainer_factory.rb 2022-03-01 16:20:24.000000000 +0100 @@ -7,25 +7,26 @@ def add_global_filter(filter) strainer_class_cache.clear - global_filters << filter + GlobalCache.add_filter(filter) end def create(context, filters = []) strainer_from_cache(filters).new(context) end - private + GlobalCache = Class.new(StrainerTemplate) - def global_filters - @global_filters ||= [] - end + private def strainer_from_cache(filters) - strainer_class_cache[filters] ||= begin - klass = Class.new(StrainerTemplate) - global_filters.each { |f| klass.add_filter(f) } - filters.each { |f| klass.add_filter(f) } - klass + if filters.empty? + GlobalCache + else + strainer_class_cache[filters] ||= begin + klass = Class.new(GlobalCache) + filters.each { |f| klass.add_filter(f) } + klass + end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/liquid/strainer_template.rb new/lib/liquid/strainer_template.rb --- old/lib/liquid/strainer_template.rb 2021-09-15 21:16:18.000000000 +0200 +++ new/lib/liquid/strainer_template.rb 2022-03-01 16:20:24.000000000 +0100 @@ -31,6 +31,11 @@ filter_methods.include?(method.to_s) end + def inherited(subclass) + super + subclass.instance_variable_set(:@filter_methods, @filter_methods.dup) + end + private def filter_methods diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/liquid/version.rb new/lib/liquid/version.rb --- old/lib/liquid/version.rb 2021-09-15 21:16:18.000000000 +0200 +++ new/lib/liquid/version.rb 2022-03-01 16:20:24.000000000 +0100 @@ -2,5 +2,5 @@ # frozen_string_literal: true module Liquid - VERSION = "5.1.0" + VERSION = "5.2.0" end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/liquid.rb new/lib/liquid.rb --- old/lib/liquid.rb 2021-09-15 21:16:18.000000000 +0200 +++ new/lib/liquid.rb 2022-03-01 16:20:24.000000000 +0100 @@ -36,7 +36,7 @@ VariableIncompleteEnd = /\}\}?/ QuotedString = /"[^"]*"|'[^']*'/ QuotedFragment = /#{QuotedString}|(?:[^\s,\|'"]|#{QuotedString})+/o - TagAttributes = /(\w+)\s*\:\s*(#{QuotedFragment})/o + TagAttributes = /(\w[\w-]*)\s*\:\s*(#{QuotedFragment})/o AnyStartingTag = /#{TagStart}|#{VariableStart}/o PartialTemplateParser = /#{TagStart}.*?#{TagEnd}|#{VariableStart}.*?#{VariableIncompleteEnd}/om TemplateParser = /(#{PartialTemplateParser}|#{AnyStartingTag})/om @@ -59,8 +59,8 @@ require 'liquid/extensions' require 'liquid/errors' require 'liquid/interrupts' -require 'liquid/strainer_factory' require 'liquid/strainer_template' +require 'liquid/strainer_factory' require 'liquid/expression' require 'liquid/context' require 'liquid/parser_switching' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2021-09-15 21:16:18.000000000 +0200 +++ new/metadata 2022-03-01 16:20:24.000000000 +0100 @@ -1,14 +1,14 @@ --- !ruby/object:Gem::Specification name: liquid version: !ruby/object:Gem::Version - version: 5.1.0 + version: 5.2.0 platform: ruby authors: - Tobias L??tke autorequire: bindir: bin cert_chain: [] -date: 2021-09-15 00:00:00.000000000 Z +date: 2022-03-01 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: rake @@ -120,6 +120,7 @@ - test/integration/drop_test.rb - test/integration/error_handling_test.rb - test/integration/expression_test.rb +- test/integration/filter_kwarg_test.rb - test/integration/filter_test.rb - test/integration/hash_ordering_test.rb - test/integration/output_test.rb @@ -192,60 +193,61 @@ specification_version: 4 summary: A secure, non-evaling end user template engine with aesthetic markup. test_files: -- test/test_helper.rb -- test/fixtures/en_locale.yml -- test/unit/strainer_factory_unit_test.rb -- test/unit/regexp_unit_test.rb -- test/unit/static_registers_unit_test.rb -- test/unit/template_unit_test.rb -- test/unit/partial_cache_unit_test.rb -- test/unit/block_unit_test.rb -- test/unit/parse_tree_visitor_test.rb -- test/unit/parser_unit_test.rb -- test/unit/i18n_unit_test.rb -- test/unit/file_system_unit_test.rb -- test/unit/tags/case_tag_unit_test.rb -- test/unit/tags/if_tag_unit_test.rb -- test/unit/tags/for_tag_unit_test.rb -- test/unit/tokenizer_unit_test.rb -- test/unit/template_factory_unit_test.rb -- test/unit/lexer_unit_test.rb -- test/unit/condition_unit_test.rb -- test/unit/tag_unit_test.rb -- test/unit/strainer_template_unit_test.rb -- test/unit/variable_unit_test.rb -- test/integration/error_handling_test.rb -- test/integration/tag_test.rb -- test/integration/filter_test.rb -- test/integration/context_test.rb -- test/integration/block_test.rb -- test/integration/template_test.rb -- test/integration/profiler_test.rb -- test/integration/parsing_quirks_test.rb - test/integration/tag/disableable_test.rb +- test/integration/parsing_quirks_test.rb +- test/integration/context_test.rb +- test/integration/filter_kwarg_test.rb +- test/integration/capture_test.rb - test/integration/trim_mode_test.rb -- test/integration/expression_test.rb - test/integration/output_test.rb -- test/integration/security_test.rb -- test/integration/drop_test.rb -- test/integration/tags/increment_tag_test.rb - test/integration/tags/raw_tag_test.rb +- test/integration/tags/continue_tag_test.rb +- test/integration/tags/increment_tag_test.rb - test/integration/tags/if_else_tag_test.rb +- test/integration/tags/table_row_test.rb - test/integration/tags/include_tag_test.rb -- test/integration/tags/statements_test.rb - test/integration/tags/break_tag_test.rb -- test/integration/tags/render_tag_test.rb -- test/integration/tags/continue_tag_test.rb -- test/integration/tags/table_row_test.rb - test/integration/tags/unless_else_tag_test.rb -- test/integration/tags/echo_test.rb - test/integration/tags/standard_tag_test.rb -- test/integration/tags/liquid_tag_test.rb - test/integration/tags/for_tag_test.rb +- test/integration/tags/statements_test.rb +- test/integration/tags/liquid_tag_test.rb +- test/integration/tags/render_tag_test.rb +- test/integration/tags/echo_test.rb +- test/integration/drop_test.rb +- test/integration/error_handling_test.rb +- test/integration/template_test.rb +- test/integration/expression_test.rb - test/integration/standard_filter_test.rb +- test/integration/tag_test.rb +- test/integration/hash_ordering_test.rb +- test/integration/security_test.rb - test/integration/blank_test.rb +- test/integration/filter_test.rb - test/integration/document_test.rb +- test/integration/block_test.rb +- test/integration/profiler_test.rb - test/integration/variable_test.rb -- test/integration/hash_ordering_test.rb - test/integration/assign_test.rb -- test/integration/capture_test.rb +- test/unit/template_unit_test.rb +- test/unit/tag_unit_test.rb +- test/unit/condition_unit_test.rb +- test/unit/strainer_template_unit_test.rb +- test/unit/lexer_unit_test.rb +- test/unit/partial_cache_unit_test.rb +- test/unit/template_factory_unit_test.rb +- test/unit/tags/if_tag_unit_test.rb +- test/unit/tags/case_tag_unit_test.rb +- test/unit/tags/for_tag_unit_test.rb +- test/unit/static_registers_unit_test.rb +- test/unit/regexp_unit_test.rb +- test/unit/i18n_unit_test.rb +- test/unit/parse_tree_visitor_test.rb +- test/unit/variable_unit_test.rb +- test/unit/tokenizer_unit_test.rb +- test/unit/file_system_unit_test.rb +- test/unit/block_unit_test.rb +- test/unit/strainer_factory_unit_test.rb +- test/unit/parser_unit_test.rb +- test/test_helper.rb +- test/fixtures/en_locale.yml diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/integration/filter_kwarg_test.rb new/test/integration/filter_kwarg_test.rb --- old/test/integration/filter_kwarg_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/test/integration/filter_kwarg_test.rb 2022-03-01 16:20:24.000000000 +0100 @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +require 'test_helper' + +class FilterKwargTest < Minitest::Test + module KwargFilter + def html_tag(_tag, attributes) + attributes + .map { |key, value| "#{key}='#{value}'" } + .join(' ') + end + end + + include Liquid + + def test_can_parse_data_kwargs + with_global_filter(KwargFilter) do + assert_equal( + "data-src='src' data-widths='100, 200'", + Template.parse("{{ 'img' | html_tag: data-src: 'src', data-widths: '100, 200' }}").render(nil, nil) + ) + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/integration/standard_filter_test.rb new/test/integration/standard_filter_test.rb --- old/test/integration/standard_filter_test.rb 2021-09-15 21:16:18.000000000 +0200 +++ new/test/integration/standard_filter_test.rb 2022-03-01 16:20:24.000000000 +0100 @@ -259,8 +259,8 @@ { "price" => 1, "handle" => "gamma" }, { "price" => 2, "handle" => "epsilon" }, { "price" => 4, "handle" => "alpha" }, - { "handle" => "delta" }, { "handle" => "beta" }, + { "handle" => "delta" }, ] assert_equal(expectation, @filters.sort(input, "price")) end @@ -539,19 +539,31 @@ end def test_replace - assert_equal('2 2 2 2', @filters.replace('1 1 1 1', '1', 2)) + assert_equal('b b b b', @filters.replace('a a a a', 'a', 'b')) assert_equal('2 2 2 2', @filters.replace('1 1 1 1', 1, 2)) - assert_equal('2 1 1 1', @filters.replace_first('1 1 1 1', '1', 2)) + assert_equal('1 1 1 1', @filters.replace('1 1 1 1', 2, 3)) + assert_template_result('2 2 2 2', "{{ '1 1 1 1' | replace: '1', 2 }}") + + assert_equal('b a a a', @filters.replace_first('a a a a', 'a', 'b')) assert_equal('2 1 1 1', @filters.replace_first('1 1 1 1', 1, 2)) + assert_equal('1 1 1 1', @filters.replace_first('1 1 1 1', 2, 3)) assert_template_result('2 1 1 1', "{{ '1 1 1 1' | replace_first: '1', 2 }}") + + assert_equal('a a a b', @filters.replace_last('a a a a', 'a', 'b')) + assert_equal('1 1 1 2', @filters.replace_last('1 1 1 1', 1, 2)) + assert_equal('1 1 1 1', @filters.replace_last('1 1 1 1', 2, 3)) + assert_template_result('1 1 1 2', "{{ '1 1 1 1' | replace_last: '1', 2 }}") end def test_remove assert_equal(' ', @filters.remove("a a a a", 'a')) - assert_equal(' ', @filters.remove("1 1 1 1", 1)) - assert_equal('a a a', @filters.remove_first("a a a a", 'a ')) - assert_equal(' 1 1 1', @filters.remove_first("1 1 1 1", 1)) - assert_template_result('a a a', "{{ 'a a a a' | remove_first: 'a ' }}") + assert_template_result(' ', "{{ '1 1 1 1' | remove: 1 }}") + + assert_equal('b a a', @filters.remove_first("a b a a", 'a ')) + assert_template_result(' 1 1 1', "{{ '1 1 1 1' | remove_first: 1 }}") + + assert_equal('a a b', @filters.remove_last("a a b a", ' a')) + assert_template_result('1 1 1 ', "{{ '1 1 1 1' | remove_last: 1 }}") end def test_pipes_in_string_arguments @@ -770,6 +782,18 @@ assert_equal(expectation, @filters.where(input, "ok")) end + def test_where_string_keys + input = [ + "alpha", "beta", "gamma", "delta" + ] + + expectation = [ + "beta", + ] + + assert_equal(expectation, @filters.where(input, "be")) + end + def test_where_no_key_set input = [ { "handle" => "alpha", "ok" => true }, @@ -840,19 +864,14 @@ { 1 => "bar" }, ["foo", 123, nil, true, false, Drop, ["foo"], { foo: "bar" }], ] - test_types.each do |first| - test_types.each do |other| - (@filters.methods - Object.methods).each do |method| - arg_count = @filters.method(method).arity - arg_count *= -1 if arg_count < 0 - inputs = [first] - inputs << ([other] * (arg_count - 1)) if arg_count > 1 - begin - @filters.send(method, *inputs) - rescue Liquid::ArgumentError, Liquid::ZeroDivisionError - nil - end - end + StandardFilters.public_instance_methods(false).each do |method| + arg_count = @filters.method(method).arity + arg_count *= -1 if arg_count < 0 + + test_types.repeated_permutation(arg_count) do |args| + @filters.send(method, *args) + rescue Liquid::Error + nil end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/test_helper.rb new/test/test_helper.rb --- old/test/test_helper.rb 2021-09-15 21:16:18.000000000 +0200 +++ new/test/test_helper.rb 2022-03-01 16:20:24.000000000 +0100 @@ -72,21 +72,21 @@ end def with_global_filter(*globals) - original_global_filters = Liquid::StrainerFactory.instance_variable_get(:@global_filters) - Liquid::StrainerFactory.instance_variable_set(:@global_filters, []) - globals.each do |global| - Liquid::StrainerFactory.add_global_filter(global) - end - - Liquid::StrainerFactory.send(:strainer_class_cache).clear + original_global_cache = Liquid::StrainerFactory::GlobalCache + Liquid::StrainerFactory.send(:remove_const, :GlobalCache) + Liquid::StrainerFactory.const_set(:GlobalCache, Class.new(Liquid::StrainerTemplate)) globals.each do |global| Liquid::Template.register_filter(global) end - yield - ensure Liquid::StrainerFactory.send(:strainer_class_cache).clear - Liquid::StrainerFactory.instance_variable_set(:@global_filters, original_global_filters) + begin + yield + ensure + Liquid::StrainerFactory.send(:remove_const, :GlobalCache) + Liquid::StrainerFactory.const_set(:GlobalCache, original_global_cache) + Liquid::StrainerFactory.send(:strainer_class_cache).clear + end end def with_error_mode(mode) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/unit/strainer_factory_unit_test.rb new/test/unit/strainer_factory_unit_test.rb --- old/test/unit/strainer_factory_unit_test.rb 2021-09-15 21:16:18.000000000 +0200 +++ new/test/unit/strainer_factory_unit_test.rb 2022-03-01 16:20:24.000000000 +0100 @@ -52,7 +52,8 @@ /\ALiquid error: wrong number of arguments \((1 for 0|given 1, expected 0)\)\z/, exception.message ) - assert_equal(exception.backtrace[0].split(':')[0], __FILE__) + source = AccessScopeFilters.instance_method(:public_filter).source_location + assert_equal(source.map(&:to_s), exception.backtrace[0].split(':')[0..1]) end def test_strainer_only_invokes_public_filter_methods diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/unit/strainer_template_unit_test.rb new/test/unit/strainer_template_unit_test.rb --- old/test/unit/strainer_template_unit_test.rb 2021-09-15 21:16:18.000000000 +0200 +++ new/test/unit/strainer_template_unit_test.rb 2022-03-01 16:20:24.000000000 +0100 @@ -57,8 +57,8 @@ end def test_add_filter_does_not_raise_when_module_overrides_previously_registered_method - strainer = Context.new.strainer with_global_filter do + strainer = Context.new.strainer strainer.class.add_filter(PublicMethodOverrideFilter) assert(strainer.class.send(:filter_methods).include?('public_filter')) end
