liquid 2.5.1 → 2.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MjdlODliYmQ5MTliNTllM2NjZDIxNzE0ZGE3MjBkMGQxYjEwMWFlZQ==
5
+ data.tar.gz: !binary |-
6
+ ZmYxZmFjNTlkNGQ2ODM1YTlkZjlmZGU3ODE2MDhiOThlZTQ1MmI0Ng==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ZDQ5NjhlNmMyYTBjNDkwZjA5ZjkwMzE0Y2VkYWVlNDFhZmY4ZTExYTM3NDkw
10
+ OTI3ZmZkNzBiNjY0OTVlNWIxMjU5OWI0NGZjNjFhMjJlMzgxMGQ2NGE4ZWE0
11
+ YTllYTQwNzY5YTVlYzMyZDQ3YjM3MmIwNjExOTNlYTkyNTNhZDQ=
12
+ data.tar.gz: !binary |-
13
+ OWJjYzJhYWMzMzUzNTRkYTQxZGFiNWJjNmZiMWQ4M2YwNjk2YjU5YTY4ZTU4
14
+ MGRjODMwOWM4MmJhNzM0MDdlOTA4N2FiNjE5NjVjYzRjODg0MzFjN2VlYTRl
15
+ MDA4M2MyNWZmMzljN2E0NjlmZDJmZmI0NmFjZmM1YzQyYjJiZjE=
data/History.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Liquid Version History
2
2
 
3
+ ## 2.5.3 / branch "2.5-stable"
4
+
5
+ * #232, #234, #237: Fix map filter bugs [Florian Weingarten, fw42]
6
+
7
+ ## 2.5.2 / 2013-09-03 / deleted
8
+
9
+ Yanked from rubygems, as it contained too many changes that broke compatibility. Those changes will be on following major releases.
10
+
11
+ ## 2.5.1 / 2013-07-24
12
+
13
+ * #230: Fix security issue with map filter, Use invoke_drop in map filter [Florian Weingarten, fw42]
14
+
3
15
  ## 2.5.0 / 2013-03-06
4
16
 
5
17
  * Prevent Object methods from being called on drops
data/lib/liquid/drop.rb CHANGED
@@ -54,7 +54,7 @@ module Liquid
54
54
 
55
55
  # Check for method existence without invoking respond_to?, which creates symbols
56
56
  def self.invokable?(method_name)
57
- @invokable_methods ||= Set.new((public_instance_methods - Liquid::Drop.public_instance_methods).map(&:to_s))
57
+ @invokable_methods ||= Set.new(["to_liquid"] + (public_instance_methods - Liquid::Drop.public_instance_methods).map(&:to_s))
58
58
  @invokable_methods.include?(method_name.to_s)
59
59
  end
60
60
  end
@@ -94,7 +94,14 @@ module Liquid
94
94
  def map(input, property)
95
95
  ary = [input].flatten
96
96
  ary.map do |e|
97
- e.respond_to?('[]') ? e[property] : nil
97
+ e = e.call if e.is_a?(Proc)
98
+ e = e.to_liquid if e.respond_to?(:to_liquid)
99
+
100
+ if property == "to_liquid"
101
+ e
102
+ elsif e.respond_to?(:[])
103
+ e[property]
104
+ end
98
105
  end
99
106
  end
100
107
 
@@ -86,6 +86,11 @@ class DropsTest < Test::Unit::TestCase
86
86
  assert_equal "", Liquid::Template.parse('{{ product | map: "whatever" }}').render('product' => ProductDrop.new)
87
87
  end
88
88
 
89
+ def test_drops_respond_to_to_liquid
90
+ assert_equal "text1", Liquid::Template.parse("{{ product.to_liquid.texts.text }}").render('product' => ProductDrop.new)
91
+ assert_equal "text1", Liquid::Template.parse('{{ product | map: "to_liquid" | map: "texts" | map: "text" }}').render('product' => ProductDrop.new)
92
+ end
93
+
89
94
  def test_text_drop
90
95
  output = Liquid::Template.parse( ' {{ product.texts.text }} ' ).render('product' => ProductDrop.new)
91
96
  assert_equal ' text1 ', output
@@ -4,6 +4,27 @@ class Filters
4
4
  include Liquid::StandardFilters
5
5
  end
6
6
 
7
+ class TestThing
8
+ def initialize
9
+ @foo = 0
10
+ end
11
+
12
+ def to_s
13
+ "woot: #{@foo}"
14
+ end
15
+
16
+ def to_liquid
17
+ @foo += 1
18
+ self
19
+ end
20
+ end
21
+
22
+ class TestDrop < Liquid::Drop
23
+ def test
24
+ "testfoo"
25
+ end
26
+ end
27
+
7
28
  class StandardFiltersTest < Test::Unit::TestCase
8
29
  include Liquid
9
30
 
@@ -91,6 +112,18 @@ class StandardFiltersTest < Test::Unit::TestCase
91
112
  assert_equal "", Liquid::Template.parse('{{ "foo" | map: "inspect" }}').render
92
113
  end
93
114
 
115
+ def test_map_calls_to_liquid
116
+ t = TestThing.new
117
+ assert_equal "woot: 1", Liquid::Template.parse('{{ foo }}').render("foo" => t)
118
+ end
119
+
120
+ def test_map_over_proc
121
+ drop = TestDrop.new
122
+ p = Proc.new{ drop }
123
+ templ = '{{ procs | map: "test" }}'
124
+ assert_equal "testfoo", Liquid::Template.parse(templ).render("procs" => [p])
125
+ end
126
+
94
127
  def test_date
95
128
  assert_equal 'May', @filters.date(Time.parse("2006-05-05 10:00:00"), "%B")
96
129
  assert_equal 'June', @filters.date(Time.parse("2006-06-05 10:00:00"), "%B")
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: liquid
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.1
5
- prerelease:
4
+ version: 2.5.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Tobias Luetke
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-07-24 00:00:00.000000000 Z
11
+ date: 2013-10-09 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description:
15
14
  email:
@@ -89,27 +88,26 @@ files:
89
88
  - History.md
90
89
  homepage: http://www.liquidmarkup.org
91
90
  licenses: []
91
+ metadata: {}
92
92
  post_install_message:
93
93
  rdoc_options: []
94
94
  require_paths:
95
95
  - lib
96
96
  required_ruby_version: !ruby/object:Gem::Requirement
97
- none: false
98
97
  requirements:
99
98
  - - ! '>='
100
99
  - !ruby/object:Gem::Version
101
100
  version: '0'
102
101
  required_rubygems_version: !ruby/object:Gem::Requirement
103
- none: false
104
102
  requirements:
105
103
  - - ! '>='
106
104
  - !ruby/object:Gem::Version
107
105
  version: 1.3.7
108
106
  requirements: []
109
107
  rubyforge_project:
110
- rubygems_version: 1.8.23
108
+ rubygems_version: 2.1.6
111
109
  signing_key:
112
- specification_version: 3
110
+ specification_version: 4
113
111
  summary: A secure, non-evaling end user template engine with aesthetic markup.
114
112
  test_files:
115
113
  - test/liquid/assign_test.rb