safe_redirection 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
@@ -12,11 +12,15 @@ module SafeRedirection
|
|
12
12
|
uri = URI(redirect_url)
|
13
13
|
path = relative_path(uri.path)
|
14
14
|
|
15
|
-
if %w{http https}.include? uri.scheme
|
16
|
-
resolver.recognize_path(path, :method => :get)
|
15
|
+
if %w{http https}.include?(uri.scheme) || uri.scheme.nil?
|
16
|
+
resolver.recognize_path(path, :method => :get)
|
17
17
|
else
|
18
18
|
default_url
|
19
19
|
end
|
20
|
+
rescue SafeRedirection::SanitizationCancelled
|
21
|
+
redirect_url
|
22
|
+
rescue
|
23
|
+
default_url
|
20
24
|
end
|
21
25
|
|
22
26
|
def base_path
|
@@ -37,6 +37,14 @@ describe SafeRedirection::Sanitizer do
|
|
37
37
|
subject.safe_url_for('http://test.tld/some/path/subpath')
|
38
38
|
end
|
39
39
|
end
|
40
|
+
|
41
|
+
context "when the resolver raises SafeRedirection::SanitizationCancelled" do
|
42
|
+
it "returns the URL passed" do
|
43
|
+
resolver.stub(:recognize_path).and_raise(SafeRedirection::SanitizationCancelled)
|
44
|
+
url = '/some/path?param=value'
|
45
|
+
subject.safe_url_for(url).should == url
|
46
|
+
end
|
47
|
+
end
|
40
48
|
end
|
41
49
|
|
42
50
|
describe "#base_path" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: safe_redirection
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -104,5 +104,5 @@ rubyforge_project:
|
|
104
104
|
rubygems_version: 1.8.24
|
105
105
|
signing_key:
|
106
106
|
specification_version: 3
|
107
|
-
summary: safe_redirection-0.0.
|
107
|
+
summary: safe_redirection-0.0.3
|
108
108
|
test_files: []
|