guillotine 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/guillotine.gemspec +1 -1
- data/lib/guillotine/app.rb +14 -6
- data/lib/guillotine.rb +1 -1
- metadata +7 -7
data/guillotine.gemspec
CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
|
|
13
13
|
## If your rubyforge_project name is different, then edit it and comment out
|
14
14
|
## the sub! line in the Rakefile
|
15
15
|
s.name = 'guillotine'
|
16
|
-
s.version = '1.0.
|
16
|
+
s.version = '1.0.5'
|
17
17
|
s.date = '2011-11-10'
|
18
18
|
s.rubyforge_project = 'guillotine'
|
19
19
|
|
data/lib/guillotine/app.rb
CHANGED
@@ -9,7 +9,7 @@ module Guillotine
|
|
9
9
|
if url = settings.db.find(Addressable::URI.escape(code))
|
10
10
|
redirect settings.db.parse_url(url).to_s
|
11
11
|
else
|
12
|
-
halt 404, "No url found for #{code}"
|
12
|
+
halt 404, simple_escape("No url found for #{code}")
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -17,17 +17,17 @@ module Guillotine
|
|
17
17
|
url = settings.db.parse_url params[:url].to_s
|
18
18
|
|
19
19
|
if !(url && url.scheme =~ /^https?$/)
|
20
|
-
halt 422, "Invalid url: #{url}"
|
20
|
+
halt 422, simple_escape("Invalid url: #{url}")
|
21
21
|
end
|
22
22
|
|
23
23
|
case settings.required_host
|
24
24
|
when String
|
25
25
|
if url.host != settings.required_host
|
26
|
-
halt 422, "URL must be from #{settings.required_host}"
|
26
|
+
halt 422, simple_escape("URL must be from #{settings.required_host}")
|
27
27
|
end
|
28
28
|
when Regexp
|
29
29
|
if url.host.to_s !~ settings.required_host
|
30
|
-
halt 422, "URL must match #{settings.required_host.inspect}"
|
30
|
+
halt 422, simple_escape("URL must match #{settings.required_host.inspect}")
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
@@ -35,11 +35,19 @@ module Guillotine
|
|
35
35
|
if code = settings.db.add(url.to_s, params[:code])
|
36
36
|
redirect code, 201
|
37
37
|
else
|
38
|
-
halt 422, "Unable to shorten #{url}"
|
38
|
+
halt 422, simple_escape("Unable to shorten #{url}")
|
39
39
|
end
|
40
40
|
rescue Guillotine::DuplicateCodeError => err
|
41
|
-
halt 422, err.to_s
|
41
|
+
halt 422, simple_escape(err.to_s)
|
42
42
|
end
|
43
43
|
end
|
44
|
+
|
45
|
+
# Guillotine output is supposed to be text/plain friendly, so only strip
|
46
|
+
# /<|>/. Broken tie fighter :( If you're passing these characters in,
|
47
|
+
# you're probably doing something naughty.
|
48
|
+
def simple_escape(s)
|
49
|
+
s.gsub! /<|>/, ''
|
50
|
+
s
|
51
|
+
end
|
44
52
|
end
|
45
53
|
end
|
data/lib/guillotine.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guillotine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-11-10 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sinatra
|
16
|
-
requirement: &
|
16
|
+
requirement: &70237903245740 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.2.6
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70237903245740
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: addressable
|
27
|
-
requirement: &
|
27
|
+
requirement: &70237903244540 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 2.2.6
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70237903244540
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rack-test
|
38
|
-
requirement: &
|
38
|
+
requirement: &70237903244140 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70237903244140
|
47
47
|
description: Adaptable private URL shortener
|
48
48
|
email: technoweenie@gmail.com
|
49
49
|
executables: []
|