mirror of
https://github.com/kemko/liquid.git
synced 2026-01-06 10:15:40 +03:00
Compare commits
8 Commits
v2.5.3
...
2-5-stable
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
46b7fd29df | ||
|
|
34f07dda59 | ||
|
|
712d97e37d | ||
|
|
ca72282dff | ||
|
|
e8a3fd10d4 | ||
|
|
e77b1a09b6 | ||
|
|
73b39beef2 | ||
|
|
fc63219087 |
12
History.md
12
History.md
@@ -1,6 +1,16 @@
|
|||||||
# Liquid Version History
|
# Liquid Version History
|
||||||
|
|
||||||
## 2.5.3 / branch "2.5-stable"
|
## 2.5.5 / 2014-01-10 / branch "2-5-stable"
|
||||||
|
|
||||||
|
Security fix, cherry-picked from master (4e14a65):
|
||||||
|
* Don't call to_sym when creating conditions for security reasons, see #273 [Bouke van der Bijl, bouk]
|
||||||
|
* Prevent arbitrary method invocation on condition objects, see #274 [Dylan Thacker-Smith, dylanahsmith]
|
||||||
|
|
||||||
|
## 2.5.4 / 2013-11-11
|
||||||
|
|
||||||
|
* Fix "can't convert Fixnum into String" for "replace", see #173, [wǒ_is神仙, jsw0528]
|
||||||
|
|
||||||
|
## 2.5.3 / 2013-10-09
|
||||||
|
|
||||||
* #232, #234, #237: Fix map filter bugs [Florian Weingarten, fw42]
|
* #232, #234, #237: Fix map filter bugs [Florian Weingarten, fw42]
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ module Liquid
|
|||||||
'index0' => index,
|
'index0' => index,
|
||||||
'col' => col + 1,
|
'col' => col + 1,
|
||||||
'col0' => col,
|
'col0' => col,
|
||||||
'index0' => index,
|
|
||||||
'rindex' => length - index,
|
'rindex' => length - index,
|
||||||
'rindex0' => length - index - 1,
|
'rindex0' => length - index - 1,
|
||||||
'first' => (index == 0),
|
'first' => (index == 0),
|
||||||
|
|||||||
@@ -107,12 +107,12 @@ module Liquid
|
|||||||
|
|
||||||
# Replace occurrences of a string with another
|
# Replace occurrences of a string with another
|
||||||
def replace(input, string, replacement = '')
|
def replace(input, string, replacement = '')
|
||||||
input.to_s.gsub(string, replacement)
|
input.to_s.gsub(string, replacement.to_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Replace the first occurrences of a string with another
|
# Replace the first occurrences of a string with another
|
||||||
def replace_first(input, string, replacement = '')
|
def replace_first(input, string, replacement = '')
|
||||||
input.to_s.sub(string, replacement)
|
input.to_s.sub(string, replacement.to_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
# remove a substring
|
# remove a substring
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ module Liquid
|
|||||||
SyntaxHelp = "Syntax Error in tag 'if' - Valid syntax: if [expression]"
|
SyntaxHelp = "Syntax Error in tag 'if' - Valid syntax: if [expression]"
|
||||||
Syntax = /(#{QuotedFragment})\s*([=!<>a-z_]+)?\s*(#{QuotedFragment})?/o
|
Syntax = /(#{QuotedFragment})\s*([=!<>a-z_]+)?\s*(#{QuotedFragment})?/o
|
||||||
ExpressionsAndOperators = /(?:\b(?:\s?and\s?|\s?or\s?)\b|(?:\s*(?!\b(?:\s?and\s?|\s?or\s?)\b)(?:#{QuotedFragment}|\S+)\s*)+)/o
|
ExpressionsAndOperators = /(?:\b(?:\s?and\s?|\s?or\s?)\b|(?:\s*(?!\b(?:\s?and\s?|\s?or\s?)\b)(?:#{QuotedFragment}|\S+)\s*)+)/o
|
||||||
|
BOOLEAN_OPERATORS = %w(and or)
|
||||||
|
|
||||||
def initialize(tag_name, markup, tokens)
|
def initialize(tag_name, markup, tokens)
|
||||||
@blocks = []
|
@blocks = []
|
||||||
@@ -61,7 +62,8 @@ module Liquid
|
|||||||
raise(SyntaxError, SyntaxHelp) unless expressions.shift.to_s =~ Syntax
|
raise(SyntaxError, SyntaxHelp) unless expressions.shift.to_s =~ Syntax
|
||||||
|
|
||||||
new_condition = Condition.new($1, $2, $3)
|
new_condition = Condition.new($1, $2, $3)
|
||||||
new_condition.send(operator.to_sym, condition)
|
raise SyntaxError, "invalid boolean operator" unless BOOLEAN_OPERATORS.include?(operator)
|
||||||
|
new_condition.send(operator, condition)
|
||||||
condition = new_condition
|
condition = new_condition
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -71,8 +73,6 @@ module Liquid
|
|||||||
@blocks.push(block)
|
@blocks.push(block)
|
||||||
@nodelist = block.attach(Array.new)
|
@nodelist = block.attach(Array.new)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Template.register_tag('if', If)
|
Template.register_tag('if', If)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
Gem::Specification.new do |s|
|
Gem::Specification.new do |s|
|
||||||
s.name = "liquid"
|
s.name = "liquid"
|
||||||
s.version = "2.5.3"
|
s.version = "2.5.5"
|
||||||
s.platform = Gem::Platform::RUBY
|
s.platform = Gem::Platform::RUBY
|
||||||
s.summary = "A secure, non-evaling end user template engine with aesthetic markup."
|
s.summary = "A secure, non-evaling end user template engine with aesthetic markup."
|
||||||
s.authors = ["Tobias Luetke"]
|
s.authors = ["Tobias Luetke"]
|
||||||
|
|||||||
@@ -157,9 +157,9 @@ class StandardFiltersTest < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_replace
|
def test_replace
|
||||||
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 '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_template_result 'b a a a', "{{ 'a a a a' | replace_first: 'a', 'b' }}"
|
assert_template_result '2 1 1 1', "{{ '1 1 1 1' | replace_first: '1', 2 }}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_remove
|
def test_remove
|
||||||
|
|||||||
@@ -157,4 +157,10 @@ class IfElseTagTest < Test::Unit::TestCase
|
|||||||
assert_template_result('yes',
|
assert_template_result('yes',
|
||||||
%({% if 'gnomeslab-and-or-liquid' contains 'gnomeslab-and-or-liquid' %}yes{% endif %}))
|
%({% if 'gnomeslab-and-or-liquid' contains 'gnomeslab-and-or-liquid' %}yes{% endif %}))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_operators_are_whitelisted
|
||||||
|
assert_raise(SyntaxError) do
|
||||||
|
assert_template_result('', %({% if 1 or throw or or 1 %}yes{% endif %}))
|
||||||
|
end
|
||||||
|
end
|
||||||
end # IfElseTest
|
end # IfElseTest
|
||||||
|
|||||||
Reference in New Issue
Block a user