1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
Description: Fix compatibility with liquid 5.5.0
Make ParseContext#parse_expression accept extra arguments that started
being passed in liquid >= 5.5.0 (safe flag / parser context).
Also update the invalid UTF-8 test to expect TemplateEncodingError instead
of ArgumentError, which has been the behavior since liquid 5.5.0.
Author: Simon Quigley <tsimonq2@debian.org>
Origin: vendor
Forwarded: not-needed
Last-Update: 2026-03-16
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/lib/liquid/c.rb
+++ b/lib/liquid/c.rb
@@ -84,7 +84,7 @@ Liquid::ParseContext.class_eval do
ruby_new_tokenizer(source, start_line_number: start_line_number, for_liquid_tag: for_liquid_tag)
end
- def parse_expression(markup)
+ def parse_expression(markup, *args, **kwargs)
if liquid_c_nodes_disabled?
Liquid::Expression.parse(markup)
else
--- a/test/unit/variable_test.rb
+++ b/test/unit/variable_test.rb
@@ -284,41 +284,15 @@ class VariableTest < Minitest::Test
end
def test_invalid_utf8_sequence
- # 2 byte character with 1 byte missing
- exc = assert_raises(ArgumentError) do
- variable_strict_parse("\xC0")
- end
- assert_equal("invalid byte sequence in UTF-8", exc.message)
-
- # 3 byte character with 1 byte missing
- exc = assert_raises(ArgumentError) do
- variable_strict_parse("\xE0\x01")
- end
- assert_equal("invalid byte sequence in UTF-8", exc.message)
-
- # 3 byte character with 2 byte missing
- exc = assert_raises(ArgumentError) do
- variable_strict_parse("\xE0")
- end
- assert_equal("invalid byte sequence in UTF-8", exc.message)
-
- # 4 byte character with 1 byte missing
- exc = assert_raises(ArgumentError) do
- variable_strict_parse("\xF0\x01\x01")
- end
- assert_equal("invalid byte sequence in UTF-8", exc.message)
-
- # 4 byte character with 2 byte missing
- exc = assert_raises(ArgumentError) do
- variable_strict_parse("\xF0\x01")
- end
- assert_equal("invalid byte sequence in UTF-8", exc.message)
+ exc_class = Liquid::VERSION >= Gem::Version.new("5.5.0") ? Liquid::TemplateEncodingError : ArgumentError
+ expected_msg = Liquid::VERSION >= Gem::Version.new("5.5.0") ? "Liquid error: Invalid template encoding" : "invalid byte sequence in UTF-8"
- # 4 byte character with 3 byte missing
- exc = assert_raises(ArgumentError) do
- variable_strict_parse("\xF0")
+ ["\xC0", "\xE0\x01", "\xE0", "\xF0\x01\x01", "\xF0\x01", "\xF0"].each do |bad|
+ exc = assert_raises(exc_class) do
+ variable_strict_parse(bad)
+ end
+ assert_equal(expected_msg, exc.message)
end
- assert_equal("invalid byte sequence in UTF-8", exc.message)
end
private
|