go_to_param 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/go_to_param/version.rb +1 -1
- data/lib/go_to_param.rb +8 -1
- data/spec/go_to_param_spec.rb +11 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ff657dfce2b1757a637ff58b8614803f96415b4
|
4
|
+
data.tar.gz: 446aaba35e959473a3ec0df17e3ada34ee91a831
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d882496e336ab925a45599ad950c2c2541c8b6a3b798eea41b1cf75aa7982747b0c9a3481c4c9e17090deb3ed84d3610b5f74054497ac79b3b422ac95ee7e9e
|
7
|
+
data.tar.gz: 405bed370bc54b4a81c0ddecc8968ad31ea3e7d0de39207433ec77b65651fd296026299a474196a9410db868f97862c79796f1a9f465c3cb13a53ddb055c3461
|
data/lib/go_to_param/version.rb
CHANGED
data/lib/go_to_param.rb
CHANGED
@@ -47,7 +47,7 @@ module GoToParam
|
|
47
47
|
|
48
48
|
def go_to_here_path(additional_query_params = {})
|
49
49
|
if request.get?
|
50
|
-
_go_to_add_query_string_from_hash(
|
50
|
+
_go_to_add_query_string_from_hash(_go_to_fullpath, additional_query_params)
|
51
51
|
else
|
52
52
|
nil
|
53
53
|
end
|
@@ -67,4 +67,11 @@ module GoToParam
|
|
67
67
|
[ path, separator, query_string ].join
|
68
68
|
end
|
69
69
|
end
|
70
|
+
|
71
|
+
# Prevent encoding errors ("incompatible character encodings: UTF-8 and ASCII-8BIT") for certain malformed requests.
|
72
|
+
# Inspired by https://github.com/discourse/discourse/commit/090dc80f8a23dbb3ad703efbac990aa917c06505
|
73
|
+
def _go_to_fullpath
|
74
|
+
path = request.fullpath
|
75
|
+
path.dup.force_encoding("UTF-8").scrub
|
76
|
+
end
|
70
77
|
end
|
data/spec/go_to_param_spec.rb
CHANGED
@@ -99,6 +99,17 @@ describe GoToParam do
|
|
99
99
|
expect(controller.go_to_here_params(bar: 3)).to eq({ go_to: "/example?foo&bar=3" })
|
100
100
|
end
|
101
101
|
|
102
|
+
it "makes sure the go_to path is valid UTF-8" do
|
103
|
+
weird_path = "\xE0\x80\x80weird\330stuff".force_encoding("ASCII-8BIT")
|
104
|
+
replacement = "\uFFFD" # The Unicode 'Replacement Character'
|
105
|
+
|
106
|
+
controller.request = double(get?: true, fullpath: weird_path)
|
107
|
+
|
108
|
+
go_to_value = controller.go_to_here_params[:go_to]
|
109
|
+
|
110
|
+
expect(go_to_value.encoding).to eq(Encoding::UTF_8)
|
111
|
+
expect(go_to_value).to eq("#{replacement}#{replacement}#{replacement}weird#{replacement}stuff")
|
112
|
+
end
|
102
113
|
end
|
103
114
|
|
104
115
|
describe "#go_to_path" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: go_to_param
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henrik N
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|