optic14n 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.ruby-version +2 -0
- data/Gemfile +2 -2
- data/lib/optic14n/version.rb +1 -1
- data/lib/uri/bluri.rb +3 -3
- data/spec/c14n_spec.rb +33 -0
- metadata +15 -28
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: faf613071e1b6009e6a97058aa8ccc17e537b88e
|
4
|
+
data.tar.gz: 87274484cb0115cae18914eb1ee8edeb070b1ca5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cde69422152d68439c35298f616876c82d6ed32ec8ae4efb92926326873a8c639f7fed718a7782c2a60b62b2e38f5b7b5585314988fb4863730b41bd41490b6b
|
7
|
+
data.tar.gz: aa2d3e22503736c3e0c86ebc243ddff0d85adf00d381a40fc7639fb9bb9a56dec0e43235c9cec2297479ae4e1d28ee01811ba6228e8ce6766d6e8c7e78d4e357
|
data/.ruby-version
ADDED
data/Gemfile
CHANGED
data/lib/optic14n/version.rb
CHANGED
data/lib/uri/bluri.rb
CHANGED
@@ -79,10 +79,10 @@ module URI
|
|
79
79
|
|
80
80
|
def canonicalize_query!(options)
|
81
81
|
allow_all = (options[:allow_query] == :all)
|
82
|
-
allowed_keys = [options[:allow_query]].flatten.compact unless allow_all
|
82
|
+
allowed_keys = [options[:allow_query]].flatten.compact.map(&:to_s) unless allow_all
|
83
83
|
|
84
84
|
query_hash.keep_if do |k, _|
|
85
|
-
allow_all || (allowed_keys.include?(k
|
85
|
+
allow_all || (allowed_keys.include?(k.to_s))
|
86
86
|
end
|
87
87
|
|
88
88
|
self.query_hash = QueryHash[query_hash.sort_by { |k, _| k }]
|
@@ -113,4 +113,4 @@ module Kernel
|
|
113
113
|
end
|
114
114
|
|
115
115
|
module_function :BLURI
|
116
|
-
end
|
116
|
+
end
|
data/spec/c14n_spec.rb
CHANGED
@@ -132,6 +132,35 @@ describe "Paul's tests, translated from Perl" do
|
|
132
132
|
@bluri.query_hash.to_s.should == 'bar&foo'
|
133
133
|
end
|
134
134
|
end
|
135
|
+
|
136
|
+
describe 'casing of allowed query params' do
|
137
|
+
context 'when the query param contains upper-case letters' do
|
138
|
+
it 'does not preserve the query string, even when it appeared identically in the URL' do
|
139
|
+
BLURI('http://www.example.com/?Foo=bar').canonicalize!(allow_query: 'Foo').to_s.should ==
|
140
|
+
'http://www.example.com'
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
context 'when the query param is lower-cased' do
|
145
|
+
it 'preserves the query string and lower-cases it' do
|
146
|
+
BLURI('http://www.example.com/?Foo=bar').canonicalize!(allow_query: 'foo').to_s.should ==
|
147
|
+
'http://www.example.com?foo=bar'
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
describe 'indifferent specfication of allowed query params' do
|
153
|
+
context 'specifying the allowed query param using either a symbol or a string' do
|
154
|
+
it 'should behave the same' do
|
155
|
+
url = 'http://example.com/some?significant=1&query_params=2'
|
156
|
+
|
157
|
+
using_symbol = BLURI(url).canonicalize!(allow_query: :significant)
|
158
|
+
using_string = BLURI(url).canonicalize!(allow_query: 'significant')
|
159
|
+
|
160
|
+
using_symbol.should == using_string
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
135
164
|
end
|
136
165
|
|
137
166
|
describe 'degenerate cases' do
|
@@ -148,6 +177,10 @@ describe "Paul's tests, translated from Perl" do
|
|
148
177
|
canonicalize!(allow_query: :all).
|
149
178
|
to_s.should eql('http://example.com/path?%ED=view')
|
150
179
|
end
|
180
|
+
|
181
|
+
it 'does not error when there are bad things in query keys when allow_query isn\'t :all' do
|
182
|
+
expect { BLURI('http://some.com/a/path?%E2').canonicalize! }.not_to raise_error
|
183
|
+
end
|
151
184
|
end
|
152
185
|
|
153
186
|
describe 'failure to canonicalize paths correctly' do
|
metadata
CHANGED
@@ -1,62 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: optic14n
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
5
|
-
prerelease:
|
4
|
+
version: 2.0.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Russell Garner
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2016-07-27 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: addressable
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- - ~>
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '2.3'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- - ~>
|
24
|
+
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '2.3'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rake
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: gem_publisher
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- - ~>
|
45
|
+
- - "~>"
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: 1.3.0
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- - ~>
|
52
|
+
- - "~>"
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: 1.3.0
|
62
55
|
description: Canonicalises URLs.
|
@@ -66,7 +59,8 @@ executables: []
|
|
66
59
|
extensions: []
|
67
60
|
extra_rdoc_files: []
|
68
61
|
files:
|
69
|
-
- .gitignore
|
62
|
+
- ".gitignore"
|
63
|
+
- ".ruby-version"
|
70
64
|
- Gemfile
|
71
65
|
- LICENSE.txt
|
72
66
|
- README.md
|
@@ -89,33 +83,26 @@ files:
|
|
89
83
|
homepage: ''
|
90
84
|
licenses:
|
91
85
|
- MIT
|
86
|
+
metadata: {}
|
92
87
|
post_install_message:
|
93
88
|
rdoc_options: []
|
94
89
|
require_paths:
|
95
90
|
- lib
|
96
91
|
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
92
|
requirements:
|
99
|
-
- -
|
93
|
+
- - ">="
|
100
94
|
- !ruby/object:Gem::Version
|
101
95
|
version: '0'
|
102
|
-
segments:
|
103
|
-
- 0
|
104
|
-
hash: 2602697415991458495
|
105
96
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
-
none: false
|
107
97
|
requirements:
|
108
|
-
- -
|
98
|
+
- - ">="
|
109
99
|
- !ruby/object:Gem::Version
|
110
100
|
version: '0'
|
111
|
-
segments:
|
112
|
-
- 0
|
113
|
-
hash: 2602697415991458495
|
114
101
|
requirements: []
|
115
102
|
rubyforge_project:
|
116
|
-
rubygems_version:
|
103
|
+
rubygems_version: 2.5.1
|
117
104
|
signing_key:
|
118
|
-
specification_version:
|
105
|
+
specification_version: 4
|
119
106
|
summary: Specifically, HTTP URLs, for a limited purpose
|
120
107
|
test_files:
|
121
108
|
- spec/bluri_spec.rb
|