mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-12 23:40:45 -07:00
Fix filter parser regex for filter args without separating spaces.
The regex was using \S+ to match the comma between the filters arguments, but would continue to match idependent quote characters and filter separators. This can result in multiple filters being interpreted as a single one with many arguments.
This commit is contained in:
@@ -11,7 +11,7 @@ module Liquid
|
|||||||
# {{ user | link }}
|
# {{ user | link }}
|
||||||
#
|
#
|
||||||
class Variable
|
class Variable
|
||||||
FilterParser = /(?:#{FilterSeparator}|(?:\s*(?!(?:#{FilterSeparator}))(?:#{QuotedFragment}|\S+)\s*)+)/o
|
FilterParser = /(?:#{FilterSeparator}|(?:\s*(?:#{QuotedFragment}|#{ArgumentSeparator})\s*)+)/o
|
||||||
attr_accessor :filters, :name
|
attr_accessor :filters, :name
|
||||||
|
|
||||||
def initialize(markup)
|
def initialize(markup)
|
||||||
|
|||||||
@@ -66,6 +66,10 @@ class VariableTest < Test::Unit::TestCase
|
|||||||
var = Variable.new('hello|textileze|paragraph')
|
var = Variable.new('hello|textileze|paragraph')
|
||||||
assert_equal 'hello', var.name
|
assert_equal 'hello', var.name
|
||||||
assert_equal [[:textileze,[]], [:paragraph,[]]], var.filters
|
assert_equal [[:textileze,[]], [:paragraph,[]]], var.filters
|
||||||
|
|
||||||
|
var = Variable.new("hello|replace:'foo','bar'|textileze")
|
||||||
|
assert_equal 'hello', var.name
|
||||||
|
assert_equal [[:replace, ["'foo'", "'bar'"]], [:textileze, []]], var.filters
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_symbol
|
def test_symbol
|
||||||
|
|||||||
Reference in New Issue
Block a user