ghoul 0.1.9 → 0.2.0
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.
- data/lib/ghoul/lib/url_helpers.rb +9 -9
- data/lib/version.rb +1 -1
- data/spec/url_helper_spec.rb +54 -0
- metadata +18 -18
@@ -13,42 +13,42 @@ module Ghoul
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def repository_path(repository)
|
16
|
-
url "/repository/#{repository}/trunk/tree"
|
16
|
+
url "/repository/#{URI.escape repository}/trunk/tree"
|
17
17
|
end
|
18
18
|
|
19
19
|
def repository_git_url(repository)
|
20
|
-
return "http://#{@request.host_with_port}/repo/#{repository}"
|
20
|
+
return "http://#{@request.host_with_port}/repo/#{URI.escape repository}"
|
21
21
|
end
|
22
22
|
|
23
23
|
def repository_settings_path(repository)
|
24
|
-
url "/repository/#{repository}/settings"
|
24
|
+
url "/repository/#{URI.escape repository}/settings"
|
25
25
|
end
|
26
26
|
|
27
27
|
def clone_url(repository)
|
28
|
-
return "http://#{@request.host_with_port}/repo/#{repository}"
|
28
|
+
return "http://#{@request.host_with_port}/repo/#{URI.escape repository}"
|
29
29
|
end
|
30
30
|
|
31
31
|
def commits_path(repository, page=1)
|
32
|
-
url "/repository/#{repository}/commits/#{page}"
|
32
|
+
url "/repository/#{URI.escape repository}/commits/#{page}"
|
33
33
|
end
|
34
34
|
|
35
35
|
def commit_path(repository, commit)
|
36
|
-
url "/repository/#{repository}/commits/#{commit}"
|
36
|
+
url "/repository/#{URI.escape repository}/commits/#{commit}"
|
37
37
|
end
|
38
38
|
|
39
39
|
def blob_for_commit_path(repository, commit, splat="", name="")
|
40
|
-
parts = [repository, commit, "tree", splat, name].find_all { |i| i != ""}
|
40
|
+
parts = [repository, commit, "tree", splat, name].find_all { |i| i != ""}.map {|i| i && URI.escape(i)}
|
41
41
|
url "/repository/#{parts.join("/")}"
|
42
42
|
end
|
43
43
|
alias_method :tree_for_commit_path, :blob_for_commit_path
|
44
44
|
|
45
45
|
def raw_blob_for_commit_path(repository, commit, splat="", name="")
|
46
|
-
parts = [repository, commit, "raw", splat, name].find_all { |i| i != ""}
|
46
|
+
parts = [repository, commit, "raw", splat, name].find_all { |i| i != ""}.map {|i| i && URI.escape(i)}
|
47
47
|
url "/repository/#{parts.join("/")}"
|
48
48
|
end
|
49
49
|
|
50
50
|
def diff_for_commit_path(repository, commit)
|
51
|
-
url "/repository/#{repository}/#{commit}/diff"
|
51
|
+
url "/repository/#{URI.escape repository}/#{commit}/diff"
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
data/lib/version.rb
CHANGED
data/spec/url_helper_spec.rb
CHANGED
@@ -12,6 +12,10 @@ describe Ghoul::UrlHelpers do
|
|
12
12
|
return url
|
13
13
|
end
|
14
14
|
|
15
|
+
def unsafe_characters
|
16
|
+
%q{#%^`{}'"\\ }
|
17
|
+
end
|
18
|
+
|
15
19
|
it "should route guides_path" do
|
16
20
|
guides_path.should == "/guides"
|
17
21
|
end
|
@@ -20,37 +24,87 @@ describe Ghoul::UrlHelpers do
|
|
20
24
|
repository_path(@repository).should == "/repository/ghoul/trunk/tree"
|
21
25
|
end
|
22
26
|
|
27
|
+
it "should route repository path for a repository with invalid URI characters" do
|
28
|
+
repository = "ghoul#{unsafe_characters}repo"
|
29
|
+
repository_path(repository).should == "/repository/#{URI.escape repository}/trunk/tree"
|
30
|
+
end
|
31
|
+
|
23
32
|
it "should route repository_git_url" do
|
24
33
|
@request.should_receive(:host_with_port).and_return("localhost:3000")
|
25
34
|
repository_git_url(@repository).should == "http://localhost:3000/repo/ghoul"
|
26
35
|
end
|
27
36
|
|
37
|
+
it "should route repository_git_url for a repository with invalid URI characters" do
|
38
|
+
repository = "ghoul#{unsafe_characters}repo"
|
39
|
+
@request.should_receive(:host_with_port).and_return("localhost:3000")
|
40
|
+
repository_git_url(repository).should == "http://localhost:3000/repo/#{URI.escape repository}"
|
41
|
+
end
|
42
|
+
|
28
43
|
it "should route repository_settings_path" do
|
29
44
|
repository_settings_path(@repository).should == "/repository/ghoul/settings"
|
30
45
|
end
|
31
46
|
|
47
|
+
it "should route repository_settings_path for a repository with invalid URI characters" do
|
48
|
+
repository = "ghoul#{unsafe_characters}repo"
|
49
|
+
repository_settings_path(repository).should == "/repository/#{URI.escape repository}/settings"
|
50
|
+
end
|
51
|
+
|
32
52
|
it "should route clone_url" do
|
33
53
|
@request.should_receive(:host_with_port).and_return("localhost:3000")
|
34
54
|
clone_url(@repository).should == "http://localhost:3000/repo/ghoul"
|
35
55
|
end
|
36
56
|
|
57
|
+
it "should route clone_url for a repository with invalid URI characters" do
|
58
|
+
repository = "ghoul#{unsafe_characters}repo"
|
59
|
+
@request.should_receive(:host_with_port).and_return("localhost:3000")
|
60
|
+
clone_url(repository).should == "http://localhost:3000/repo/#{URI.escape repository}"
|
61
|
+
end
|
62
|
+
|
37
63
|
it "should route commit_path" do
|
38
64
|
commit_path(@repository, "xyz").should == "/repository/ghoul/commits/xyz"
|
39
65
|
end
|
40
66
|
|
67
|
+
it "should route commit_path for a repository with invalid URI characters" do
|
68
|
+
repository = "ghoul#{unsafe_characters}repo"
|
69
|
+
commit_path(repository, "xyz").should == "/repository/#{URI.escape repository}/commits/xyz"
|
70
|
+
end
|
71
|
+
|
41
72
|
it "should route blob_for_commit_path" do
|
42
73
|
blob_for_commit_path(@repository, "xyz", "abc/def", "ruby.rb").should == "/repository/ghoul/xyz/tree/abc/def/ruby.rb"
|
43
74
|
end
|
44
75
|
|
76
|
+
it "should route blob_for_commit_path for parts with invalid URI characters" do
|
77
|
+
repository = "ghoul#{unsafe_characters}repo"
|
78
|
+
splat = "#{unsafe_characters}/#{unsafe_characters}"
|
79
|
+
name = "#{unsafe_characters}.rb"
|
80
|
+
blob_for_commit_path(repository, "xyz", splat, name).should == "/repository/#{URI.escape repository}/xyz/tree/#{URI.escape splat}/#{URI.escape name}"
|
81
|
+
end
|
82
|
+
|
45
83
|
it "should route blob_for_commit_path without a path" do
|
46
84
|
blob_for_commit_path(@repository, "xyz", "", "ruby.rb").should == "/repository/ghoul/xyz/tree/ruby.rb"
|
47
85
|
end
|
48
86
|
|
87
|
+
it "should route blob_for_commit_path with a nil name" do
|
88
|
+
blob_for_commit_path(@repository, "xyz", "", nil).should == "/repository/ghoul/xyz/tree/"
|
89
|
+
end
|
90
|
+
|
49
91
|
it "should route raw_blob_for_commit_path" do
|
50
92
|
raw_blob_for_commit_path(@repository, "commitxyz", "xyz/e/fe/fe").should == "/repository/ghoul/commitxyz/raw/xyz/e/fe/fe"
|
51
93
|
end
|
94
|
+
|
95
|
+
it "should route raw_blob_for_commit_path for repository with invalid URI characters" do
|
96
|
+
repository = "ghoul#{unsafe_characters}repo"
|
97
|
+
splat = "#{unsafe_characters}/#{unsafe_characters}"
|
98
|
+
name = "#{unsafe_characters}.rb"
|
99
|
+
raw_blob_for_commit_path(repository, "commitxyz", splat, name).should == "/repository/#{URI.escape repository}/commitxyz/raw/#{URI.escape splat}/#{URI.escape name}"
|
100
|
+
end
|
52
101
|
|
53
102
|
it "should route diff_for_commit_path" do
|
54
103
|
diff_for_commit_path(@repository, "commitxyz").should == "/repository/ghoul/commitxyz/diff"
|
55
104
|
end
|
105
|
+
|
106
|
+
it "should route diff_for_commit_path for repository with invalid URI characters" do
|
107
|
+
repository = "ghoul#{unsafe_characters}repo"
|
108
|
+
diff_for_commit_path(repository, "commitxyz").should == "/repository/#{URI.escape repository}/commitxyz/diff"
|
109
|
+
end
|
56
110
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ghoul
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-11-
|
12
|
+
date: 2011-11-09 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|
16
|
-
requirement: &
|
16
|
+
requirement: &70332330649780 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.0.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70332330649780
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: sinatra
|
27
|
-
requirement: &
|
27
|
+
requirement: &70332330648980 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - =
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.3.1
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70332330648980
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: sass
|
38
|
-
requirement: &
|
38
|
+
requirement: &70332330648320 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70332330648320
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: grit
|
49
|
-
requirement: &
|
49
|
+
requirement: &70332330647500 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70332330647500
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: georgedrummond_sinatra_helpers
|
60
|
-
requirement: &
|
60
|
+
requirement: &70332330647060 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70332330647060
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: ghoul_grack
|
71
|
-
requirement: &
|
71
|
+
requirement: &70332330646520 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - =
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: 0.0.1
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70332330646520
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: coderay
|
82
|
-
requirement: &
|
82
|
+
requirement: &70332330645960 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :runtime
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70332330645960
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: redcarpet
|
93
|
-
requirement: &
|
93
|
+
requirement: &70332330645280 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,7 +98,7 @@ dependencies:
|
|
98
98
|
version: '0'
|
99
99
|
type: :runtime
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70332330645280
|
102
102
|
description: Ghoul is a simple yet good looking interface for your git repositories
|
103
103
|
written in sinatra. It is currently only for demonstration purposes and use on your
|
104
104
|
secure local machine as it does not enforce any authentication as of yet.
|