http.rb 1.3.4 → 1.3.5
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 +4 -4
- data/CHANGELOG +13 -0
- data/lib/HTTP/VERSION.rb +1 -1
- data/lib/Thoran/String/Urlencode/urlencode.rb +7 -4
- data/test/Thoran/String/Urlencode/urlencode_test.rb +41 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b19f251bfdf7beb262c7f6fe8c00950fb580937b1679cef33059346e4695d8a4
|
|
4
|
+
data.tar.gz: 6dd0dfa38e25d6805552778398c36df2bf8e42d6f507f23fe8bde2aeb229945c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 923a61906a76fd676e1f47808ccc3d295cc9d7c6b5b977d5ec1ff9a496daf8488dfd5f49f1169b650343d66aba9d9994cc166d9caf9d2a64a9e6440c5ac3fb64
|
|
7
|
+
data.tar.gz: 672784fee166a077e19e8b79866c24b84793c9aa82c7e4bbe217cbca60565fa0ad241c3d739bb3808108a4caa9ac2f036428943c7d1337327f35b8083ddc737b
|
data/CHANGELOG
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## 20261011
|
|
4
|
+
|
|
5
|
+
1.3.5: Non-ASCII is URL-encoded in full, and without a warning.
|
|
6
|
+
|
|
7
|
+
A query argument holding a multibyte character was encoded one byte per character, so only the first byte of each went out: 'Älaskår' became '%C3lask%C3r' where it should have been '%C3%84lask%C3%A5r', and a server decoding it got invalid UTF-8. The warning this was first noticed by, "historical binary regexp match /.../n against UTF-8 string", came from the same line and is only a warning, but dropping the /n alone would have left the bytes truncated, which is what kept the warning from seeming to matter.
|
|
8
|
+
|
|
9
|
+
1. ~ Thoran::String::Urlencode#urlencode: /$1.size/$1.bytesize/, so that each byte of a character is encoded rather than the first only.
|
|
10
|
+
2. ~ Thoran::String::Urlencode#urlencode: - /n flag. Matched against a UTF-8 string, a binary regexp warns on current Ruby, and the match is the same without it: a run of non-ASCII characters is still matched whole and then unpacked byte by byte, and a binary string is still matched byte-wise.
|
|
11
|
+
3. ~ Thoran/String/Urlencode/urlencode.rb: /0.4.0/0.4.1/ in the file's own header.
|
|
12
|
+
4. + test/Thoran/String/Urlencode/urlencode_test.rb: unreserved and reserved characters, a space, two and three byte characters, a binary string, the absence of a warning, and the url_encode alias. The multibyte, warning, and alias examples fail against 1.3.4.
|
|
13
|
+
5. ~ HTTP::VERSION: /1.3.4/1.3.5/
|
|
14
|
+
|
|
15
|
+
|
|
3
16
|
## 20261011
|
|
4
17
|
|
|
5
18
|
1.3.4: ~ LICENSE: /2026/2009-2026/
|
data/lib/HTTP/VERSION.rb
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Thoran/String/Urlencode/urlencode.rb
|
|
2
2
|
# Thoran::String::Urlencode#urlencode
|
|
3
3
|
|
|
4
|
-
#
|
|
5
|
-
# 0.4.
|
|
4
|
+
# 20261011
|
|
5
|
+
# 0.4.1
|
|
6
6
|
|
|
7
7
|
# Acknowledgements: I've simply ripped off and refashioned the code from the CGI module!...
|
|
8
8
|
|
|
@@ -10,14 +10,17 @@
|
|
|
10
10
|
# -/0: More consistent naming.
|
|
11
11
|
# 1. /UrlEncode/Urlencode/
|
|
12
12
|
# 2. /url_encode/urlencode/
|
|
13
|
+
# 0/1: Non-ASCII is encoded in full, and without a warning.
|
|
14
|
+
# 3. /$1.size/$1.bytesize/: unpack('H2' * $1.size) took one byte per character, so only the first byte of a multibyte character was encoded and 'Älaskår' became '%C3lask%C3r'.
|
|
15
|
+
# 4. - /n flag: a binary regexp matched against a UTF-8 string warns on current Ruby (seen on 4.0.5), and the match is the same without it.
|
|
13
16
|
|
|
14
17
|
module Thoran
|
|
15
18
|
module String
|
|
16
19
|
module Urlencode
|
|
17
20
|
|
|
18
21
|
def urlencode
|
|
19
|
-
self.gsub(/([^ a-zA-Z0-9_.-]+)/
|
|
20
|
-
'%' + $1.unpack('H2' * $1.
|
|
22
|
+
self.gsub(/([^ a-zA-Z0-9_.-]+)/) do
|
|
23
|
+
'%' + $1.unpack('H2' * $1.bytesize).join('%').upcase
|
|
21
24
|
end.tr(' ', '+')
|
|
22
25
|
end
|
|
23
26
|
alias_method :url_encode, :urlencode
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# test/Thoran/String/Urlencode/urlencode_test.rb
|
|
2
|
+
|
|
3
|
+
require_relative '../../../helper'
|
|
4
|
+
|
|
5
|
+
describe Thoran::String::Urlencode do
|
|
6
|
+
describe "#urlencode" do
|
|
7
|
+
it "leaves unreserved characters alone" do
|
|
8
|
+
_('aZ09_.-'.urlencode).must_equal('aZ09_.-')
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "encodes a space as a plus" do
|
|
12
|
+
_('a b'.urlencode).must_equal('a+b')
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "encodes reserved characters" do
|
|
16
|
+
_('a/b?c=d&e'.urlencode).must_equal('a%2Fb%3Fc%3Dd%26e')
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "encodes every byte of a two byte character" do
|
|
20
|
+
_('Älaskår'.urlencode).must_equal('%C3%84lask%C3%A5r')
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "encodes every byte of a three byte character" do
|
|
24
|
+
_('✓'.urlencode).must_equal('%E2%9C%93')
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it "encodes a binary string byte by byte" do
|
|
28
|
+
_('Ä'.b.urlencode).must_equal('%C3%84')
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "does not warn on a UTF-8 string" do
|
|
32
|
+
_{'Älaskår'.urlencode}.must_be_silent
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
describe "#url_encode" do
|
|
37
|
+
it "is an alias of #urlencode" do
|
|
38
|
+
_('Ashër'.url_encode).must_equal('Ash%C3%ABr')
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: http.rb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.3.
|
|
4
|
+
version: 1.3.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- thoran
|
|
@@ -122,6 +122,7 @@ files:
|
|
|
122
122
|
- test/HTTP/request_without_body_test.rb
|
|
123
123
|
- test/HTTP/trace_test.rb
|
|
124
124
|
- test/Net/HTTPResponse/StatusPredicates_test.rb
|
|
125
|
+
- test/Thoran/String/Urlencode/urlencode_test.rb
|
|
125
126
|
- test/helper.rb
|
|
126
127
|
homepage: https://github.com/thoran/http
|
|
127
128
|
licenses:
|