praxis 2.0.pre.12 → 2.0.pre.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/praxis/extensions/attribute_filtering/filtering_params.rb +2 -1
- data/lib/praxis/extensions/attribute_filtering/filters_parser.rb +3 -3
- data/lib/praxis/version.rb +1 -1
- data/spec/praxis/extensions/attribute_filtering/filtering_params_spec.rb +20 -5
- data/spec/praxis/extensions/attribute_filtering/filters_parser_spec.rb +12 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c4be08481cbad0604fdb8e45dfc66aec895478a0b7578544b773af7fa6f3863f
|
4
|
+
data.tar.gz: 122625c252f5d9a2166e8958408bedf7ac5aee13500488e44c453ddeff3fbcc8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6472e4ef1f9ad601ed5c13774a336b93d52356a3a0bccb3a3707953658918a79457d314ceca1ce676a15f51c10bcebb4556388c95ba3aeca2cbec40625b13734
|
7
|
+
data.tar.gz: d8a4bad9469579530974d3c61d61fd7441b4e9d48d2ecb90ac81d4951cda0293428f750011e406e755103abb162b4fb1c60b87a584fe77da74c68dafaa997ecd
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
## next
|
4
4
|
|
5
|
+
## 2.0.pre.13
|
6
|
+
|
7
|
+
* Fix filters parser regression, which would incorrectly decode url-encoded values
|
8
|
+
|
5
9
|
## 2.0.pre.12
|
6
10
|
|
7
11
|
* Rebuilt API filters to support a much richer syntax. One can now use ANDs and ORs (with ANDs having order precedence), as well as group them with parenthesis. The same individual filter operands are supported. For example: 'email=*@gmail.com&(friends.first_name=Joe*,Patty|friends.last_name=Smith)
|
@@ -160,7 +160,8 @@ module Praxis
|
|
160
160
|
return filters if filters.is_a?(native_type)
|
161
161
|
return new if filters.nil? || filters.blank?
|
162
162
|
|
163
|
-
parsed = Parser.new.parse(
|
163
|
+
parsed = Parser.new.parse(filters)
|
164
|
+
|
164
165
|
tree = ConditionGroup.load(parsed)
|
165
166
|
|
166
167
|
rr = tree.flattened_conditions
|
@@ -24,9 +24,9 @@ module Praxis
|
|
24
24
|
@values = if values.empty?
|
25
25
|
""
|
26
26
|
elsif values.size == 1
|
27
|
-
values.first[:value].to_s
|
27
|
+
CGI.unescape(values.first[:value].to_s)
|
28
28
|
else
|
29
|
-
values.map{|e| e[:value].to_s}
|
29
|
+
values.map{|e| CGI.unescape(e[:value].to_s)}
|
30
30
|
end
|
31
31
|
else # No values for the operand
|
32
32
|
@name = triad[:name].to_sym
|
@@ -36,7 +36,7 @@ module Praxis
|
|
36
36
|
else
|
37
37
|
# Value operand without value? => convert it to empty string
|
38
38
|
raise "Interesting, didn't know this could happen. Oops!" if triad[:value].is_a?(Array) && !triad[:value].empty?
|
39
|
-
@values = (triad[:value] == []) ? '' : triad[:value].to_s # TODO: could this be an array (or it always comes the other if)
|
39
|
+
@values = (triad[:value] == []) ? '' : CGI.unescape(triad[:value].to_s) # TODO: could this be an array (or it always comes the other if)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
data/lib/praxis/version.rb
CHANGED
@@ -7,15 +7,30 @@ describe Praxis::Extensions::AttributeFiltering::FilteringParams do
|
|
7
7
|
context '.load' do
|
8
8
|
subject { described_class.load(filters_string) }
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
context 'unescapes the URL encoded values' do
|
11
|
+
it 'for single values' do
|
12
|
+
str = "one=#{CGI.escape('*')}&two>#{CGI.escape('^%$#!st_uff')}|three<normal"
|
13
|
+
parsed = [
|
14
|
+
{ name: :one, op: '=', value: '*'},
|
15
|
+
{ name: :two, op: '>', value: '^%$#!st_uff'},
|
16
|
+
{ name: :three, op: '<', value: 'normal'},
|
17
|
+
]
|
18
|
+
expect(described_class.load(str).parsed_array.map{|i| i.slice(:name,:op,:value)}).to eq(parsed)
|
19
|
+
end
|
20
|
+
it 'each of the multi-values' do
|
21
|
+
escaped_one = [
|
22
|
+
CGI.escape('fun!'),
|
23
|
+
CGI.escape('Times'),
|
24
|
+
CGI.escape('~!@#$%^&*()_+-={}|[]\:";\'<>?,./`')
|
25
|
+
].join(',')
|
26
|
+
str = "one=#{escaped_one}&two>normal"
|
12
27
|
parsed = [
|
13
|
-
{ name: :one, op: '=', value: [
|
14
|
-
{ name: :two, op: '>', value:
|
15
|
-
{ name: :three, op: '<', value: "^%$#!st_uff"},
|
28
|
+
{ name: :one, op: '=', value: ['fun!','Times','~!@#$%^&*()_+-={}|[]\:";\'<>?,./`']},
|
29
|
+
{ name: :two, op: '>', value: 'normal'},
|
16
30
|
]
|
17
31
|
expect(described_class.load(str).parsed_array.map{|i| i.slice(:name,:op,:value)}).to eq(parsed)
|
18
32
|
end
|
33
|
+
end
|
19
34
|
context 'parses for operator' do
|
20
35
|
described_class::VALUE_OPERATORS.each do |op|
|
21
36
|
it "#{op}" do
|
@@ -118,14 +118,23 @@ describe Praxis::Extensions::AttributeFiltering::FilteringParams::Parser do
|
|
118
118
|
'cOrN.00copia.of_thinGs.42_here=1' => 'cOrN.00copia.of_thinGs.42_here=1',
|
119
119
|
}
|
120
120
|
end
|
121
|
-
context 'supports everything (except &|(),) for values' do
|
121
|
+
context 'supports everything (except &|(),) for values (even without encoding..not allowed, but just to ensure the parser does not bomb)' do
|
122
122
|
it_behaves_like 'round-trip-properly', {
|
123
123
|
'v=1123' => 'v=1123',
|
124
124
|
'v=*foo*' => 'v=*foo*',
|
125
125
|
'v=*^%$#@!foo' => 'v=*^%$#@!foo',
|
126
|
-
'v=_
|
127
|
-
'v=_
|
126
|
+
'v=_-=\{}"?:><' => 'v=_-=\{}"?:><',
|
127
|
+
'v=_-=\{}"?:><,another_value!' => 'v=[_-=\{}"?:><,another_value!]',
|
128
128
|
}
|
129
129
|
end
|
130
|
+
context 'properly handles url-encoded values' do
|
131
|
+
it_behaves_like 'round-trip-properly', {
|
132
|
+
"v=#{CGI.escape('1123')}" => 'v=1123',
|
133
|
+
"v=#{CGI.escape('*foo*')}" => 'v=*foo*',
|
134
|
+
"v=#{CGI.escape('*^%$#@!foo')}" => 'v=*^%$#@!foo',
|
135
|
+
"v=#{CGI.escape('~!@#$%^&*()_+-={}|[]\:";\'<>?,./`')}" => 'v=~!@#$%^&*()_+-={}|[]\:";\'<>?,./`',
|
136
|
+
"v=#{CGI.escape('_-+=\{}"?:><')},#{CGI.escape('another_value!')}" => 'v=[_-+=\{}"?:><,another_value!]',
|
137
|
+
}
|
138
|
+
end
|
130
139
|
end
|
131
140
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: praxis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.pre.
|
4
|
+
version: 2.0.pre.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josep M. Blanquer
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-02-
|
12
|
+
date: 2021-02-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|