www/ruby-liquid: make it work with ruby32

Make ruby-liquid 4.0.3 work with ruby32 (and maybe ruby33).  There is newer
version 5.4.0, but www/ruby-jekyll dose not support liquid 5 yet.

Bump PKGREVISION.
This commit is contained in:
taca 2024-01-21 09:07:55 +00:00
parent a2560b4702
commit 481f76f850
8 changed files with 184 additions and 2 deletions

View File

@ -1,7 +1,8 @@
# $NetBSD: Makefile,v 1.10 2020/03/21 16:59:54 taca Exp $
# $NetBSD: Makefile,v 1.11 2024/01/21 09:07:55 taca Exp $
DISTNAME= liquid-4.0.3
PKGNAME= ${RUBY_PKGPREFIX}-${DISTNAME}
PKGREVISION= 1
CATEGORIES= www
MAINTAINER= minskim@NetBSD.org

View File

@ -1,5 +1,11 @@
$NetBSD: distinfo,v 1.13 2021/10/26 11:31:00 nia Exp $
$NetBSD: distinfo,v 1.14 2024/01/21 09:07:55 taca Exp $
BLAKE2s (liquid-4.0.3.gem) = 5981688731bdf62ec880d44efc3da251cdecf3d0afcc21fac645251330210623
SHA512 (liquid-4.0.3.gem) = 8f6cbc9872a92101df4994752f7692cc0f8dd5de1b81c396268f6360241d1edb2daa31c7c96ec0eee32e4cfc22909bdcd84275217cba4ce70741ff03e1482ca2
Size (liquid-4.0.3.gem) = 76288 bytes
SHA1 (patch-lib_liquid_errors.rb) = b28febbdc1528f837b3491a97be8a20298f2a5ef
SHA1 (patch-lib_liquid_standardfilters.rb) = 783ba42f957bb52196f5844f4ff86f7a587de3a1
SHA1 (patch-lib_liquid_template.rb) = 36c88f29cf5be32536c25ff825e639866c1c4405
SHA1 (patch-lib_liquid_variable.rb) = 8fbeb8c39d3226a4fdc19beb774ae1d71cb574bc
SHA1 (patch-test_integration_drop__test.rb) = c8ad57faced13378bfaf7de6ca39a1ca0e370d0e
SHA1 (patch-test_test__helper.rb) = d24e9f83eeea31c583858a1a11527d7647045836

View File

@ -0,0 +1,14 @@
$NetBSD: patch-lib_liquid_errors.rb,v 1.1 2024/01/21 09:07:55 taca Exp $
Remove support for taint checking.
--- lib/liquid/errors.rb.orig 2024-01-15 06:05:42.694834905 +0000
+++ lib/liquid/errors.rb
@@ -44,7 +44,6 @@ module Liquid
StandardError = Class.new(Error)
SyntaxError = Class.new(Error)
StackLevelError = Class.new(Error)
- TaintedError = Class.new(Error)
MemoryError = Class.new(Error)
ZeroDivisionError = Class.new(Error)
FloatDomainError = Class.new(Error)

View File

@ -0,0 +1,15 @@
$NetBSD: patch-lib_liquid_standardfilters.rb,v 1.1 2024/01/21 09:07:55 taca Exp $
Remove support for taint checking.
--- lib/liquid/standardfilters.rb.orig 2024-01-15 06:05:42.700069674 +0000
+++ lib/liquid/standardfilters.rb
@@ -39,7 +39,7 @@ module Liquid
end
def escape(input)
- CGI.escapeHTML(input.to_s).untaint unless input.nil?
+ CGI.escapeHTML(input.to_s) unless input.nil?
end
alias_method :h, :escape

View File

@ -0,0 +1,30 @@
$NetBSD: patch-lib_liquid_template.rb,v 1.1 2024/01/21 09:07:55 taca Exp $
Remove support for taint checking.
--- lib/liquid/template.rb.orig 2024-01-15 06:05:42.706300643 +0000
+++ lib/liquid/template.rb
@@ -63,12 +63,6 @@ module Liquid
# :strict will enforce correct syntax.
attr_writer :error_mode
- # Sets how strict the taint checker should be.
- # :lax is the default, and ignores the taint flag completely
- # :warn adds a warning, but does not interrupt the rendering
- # :error raises an error when tainted output is used
- attr_writer :taint_mode
-
attr_accessor :default_exception_renderer
Template.default_exception_renderer = lambda do |exception|
exception
@@ -94,10 +88,6 @@ module Liquid
@error_mode ||= :lax
end
- def taint_mode
- @taint_mode ||= :lax
- end
-
# Pass a module with filter methods which should be available
# to all liquid views. Good for registering the standard library
def register_filter(mod)

View File

@ -0,0 +1,45 @@
$NetBSD: patch-lib_liquid_variable.rb,v 1.1 2024/01/21 09:07:55 taca Exp $
Remove support for taint checking.
--- lib/liquid/variable.rb.orig 2024-01-15 06:05:42.707479051 +0000
+++ lib/liquid/variable.rb
@@ -84,11 +84,7 @@ module Liquid
context.invoke(filter_name, output, *filter_args)
end
- obj = context.apply_global_filter(obj)
-
- taint_check(context, obj)
-
- obj
+ context.apply_global_filter(obj)
end
private
@@ -120,25 +116,6 @@ module Liquid
parsed_args
end
- def taint_check(context, obj)
- return unless obj.tainted?
- return if Template.taint_mode == :lax
-
- @markup =~ QuotedFragment
- name = Regexp.last_match(0)
-
- error = TaintedError.new("variable '#{name}' is tainted and was not escaped")
- error.line_number = line_number
- error.template_name = context.template_name
-
- case Template.taint_mode
- when :warn
- context.warnings << error
- when :error
- raise error
- end
- end
-
class ParseTreeVisitor < Liquid::ParseTreeVisitor
def children
[@node.name] + @node.filters.flatten

View File

@ -0,0 +1,50 @@
$NetBSD: patch-test_integration_drop__test.rb,v 1.1 2024/01/21 09:07:55 taca Exp $
Remove support for taint checking.
--- test/integration/drop_test.rb.orig 2024-01-15 06:05:42.710512832 +0000
+++ test/integration/drop_test.rb
@@ -47,10 +47,6 @@ class ProductDrop < Liquid::Drop
ContextDrop.new
end
- def user_input
- "foo".taint
- end
-
protected
def callmenot
@@ -112,32 +108,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 }}')
- tpl.render!('product' => ProductDrop.new)
- end
- end
-
def test_drop_does_only_respond_to_whitelisted_methods
assert_equal "", Liquid::Template.parse("{{ product.inspect }}").render!('product' => ProductDrop.new)
assert_equal "", Liquid::Template.parse("{{ product.pretty_inspect }}").render!('product' => ProductDrop.new)

View File

@ -0,0 +1,21 @@
$NetBSD: patch-test_test__helper.rb,v 1.1 2024/01/21 09:07:55 taca Exp $
Remove support for taint checking.
--- test/test_helper.rb.orig 2024-01-15 06:05:42.719136612 +0000
+++ test/test_helper.rb
@@ -69,14 +69,6 @@ module Minitest
Liquid::Strainer.class_variable_set(:@@global_strainer, original_global_strainer)
end
- def with_taint_mode(mode)
- old_mode = Liquid::Template.taint_mode
- Liquid::Template.taint_mode = mode
- yield
- ensure
- Liquid::Template.taint_mode = old_mode
- end
-
def with_error_mode(mode)
old_mode = Liquid::Template.error_mode
Liquid::Template.error_mode = mode