Wiki2Go 1.17.5 → 1.22.0
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/Wiki2Go_firewall_blacklist.rb +8 -0
- data/bin/Wiki2Go_make_cvs_repository.rb +1 -0
- data/bin/Wiki2Go_make_site.rb +1 -2
- data/bin/Wiki2Go_update_site.rb +1 -2
- data/lib/Web2Go/CGIRequest.rb +8 -2
- data/lib/Web2Go/CGIResponse.rb +17 -14
- data/lib/Web2Go/MockRequest.rb +12 -2
- data/lib/Web2Go/MockResponse.rb +10 -7
- data/lib/Web2Go/WebrickRequest.rb +106 -101
- data/lib/Web2Go/WebrickResponse.rb +4 -8
- data/lib/Wiki2Go/BlackList.rb +48 -25
- data/lib/Wiki2Go/DotGraphics.rb +1 -1
- data/lib/Wiki2Go/FileStorage.rb +266 -266
- data/lib/Wiki2Go/HTMLFormatter.rb +28 -0
- data/lib/Wiki2Go/Install/config/chonqed_blacklist.txt +418 -0
- data/lib/Wiki2Go/Install/config/passwords +1 -1
- data/lib/Wiki2Go/Install/config/url_blacklist.txt +3855 -0
- data/lib/Wiki2Go/Install/make_repository.rb +32 -26
- data/lib/Wiki2Go/Install/make_site.rb +197 -111
- data/lib/Wiki2Go/Install/site/error.html +1 -1
- data/lib/Wiki2Go/Install/site/robots.txt +10 -1
- data/lib/Wiki2Go/Install/site/style.css +129 -64
- data/lib/Wiki2Go/Install/templates/admin.htm +1 -1
- data/lib/Wiki2Go/Install/templates/admin_pages/edit.txt +2 -1
- data/lib/Wiki2Go/Install/templates/admin_pages/format_for_fck.txt +31 -0
- data/lib/Wiki2Go/Install/templates/admin_pages/passwords.txt +1 -1
- data/lib/Wiki2Go/Install/templates/edit.htm +62 -46
- data/lib/Wiki2Go/Install/templates/full_footer.htm +31 -33
- data/lib/Wiki2Go/Install/templates/header.htm +0 -1
- data/lib/Wiki2Go/Install/templates/menu.htm +29 -0
- data/lib/Wiki2Go/Install/templates/pagelist.htm +46 -43
- data/lib/Wiki2Go/Install/templates/simple_footer.htm +20 -16
- data/lib/Wiki2Go/Install/templates/versionlist.htm +52 -40
- data/lib/Wiki2Go/Install/templates/view.htm +46 -29
- data/lib/Wiki2Go/Install/templates/wikiedit.htm +63 -0
- data/lib/Wiki2Go/Install/wiki/delete.png +0 -0
- data/lib/Wiki2Go/Install/wiki/style.css +133 -63
- data/lib/Wiki2Go/LineFormatter.rb +345 -197
- data/lib/Wiki2Go/Page.rb +16 -3
- data/lib/Wiki2Go/PrivateWikiConfig.rb +5 -5
- data/lib/Wiki2Go/PublicWikiConfig.rb +83 -37
- data/lib/Wiki2Go/ReadWriteWikiConfig.rb +8 -8
- data/lib/Wiki2Go/Server.rb +6 -1
- data/lib/Wiki2Go/SpamFilter.rb +32 -41
- data/lib/Wiki2Go/Web.rb +10 -3
- data/lib/Wiki2Go/Wiki2Go.rb +301 -94
- data/lib/Wiki2Go/Wiki2GoConfig.rb +87 -6
- data/lib/Wiki2Go/Wiki2GoServlet.rb +66 -12
- data/lib/Wiki2Go/WikiFormatter.rb +60 -30
- data/lib/Wiki2Go/cgi/diff.rb +20 -0
- data/lib/Wiki2Go/cgi/secure/log_rss.rb +21 -0
- data/lib/Wiki2Go/cgi/sidebyside.rb +20 -0
- data/lib/Wiki2Go/cgi/wikiedit.rb +20 -0
- data/lib/Wiki2Go/firewall_blacklist.rb +88 -0
- data/test/All.rb +5 -2
- data/test/TestBlackList.rb +70 -14
- data/test/TestConfig.rb +5 -5
- data/test/TestDiff.rb +95 -0
- data/test/TestFormatter.rb +14 -16
- data/test/TestHTMLFormatter.rb +37 -0
- data/test/TestInstall.rb +70 -27
- data/test/TestLineFormatter.rb +71 -15
- data/test/TestRSS.rb +8 -7
- data/test/TestRepository.rb +50 -0
- data/test/TestServer.rb +3 -8
- data/test/TestSpamFilter.rb +33 -1
- data/test/TestStorage.rb +11 -0
- data/test/TestWeb.rb +2 -2
- data/test/TestWiki2Go.rb +766 -166
- data/test/TestWiki2GoServlet.rb +1122 -524
- data/test/UnitTestFiles.rb +7 -3
- data/test/Wiki2GoConfigForTest.rb +40 -6
- data/test/checksite.rb +17 -50
- data/test/test_firewall_blacklist.rb +131 -0
- data/test/test_page.rb +45 -0
- data/test/testdata/Registration.rbl.txt +7 -0
- data/test/testdata/config/url_blacklist.txt +38822 -0
- data/test/testdata/expected_changes.html +1 -2
- data/test/testdata/expected_edit.html +108 -59
- data/test/testdata/expected_full_rss.xml +2 -2
- data/test/testdata/expected_out.html +97 -61
- data/test/testdata/expected_put.html +88 -53
- data/test/testdata/expected_save.html +88 -52
- data/test/testdata/expected_savehtml.html +88 -52
- data/test/testdata/expected_search.html +68 -53
- data/test/testdata/expected_upload.html +88 -53
- data/test/testdata/expected_versions.html +97 -82
- data/test/testdata/expected_view.html +97 -61
- data/test/testdata/firewall/iptables.config +37 -0
- data/test/testdata/firewall/user_blacklist.txt +162 -0
- data/test/testdata/logs/wiki.log +652 -0
- data/test/testdata/logs/wiki.log.0 +113 -0
- data/test/testdata/logs/wiki.log.1 +113 -0
- data/test/testdata/logs/wiki.log.2 +113 -0
- data/test/testdata/logs/wiki.log.3 +115 -0
- data/test/testdata/logs/wiki.log.4 +5 -0
- data/test/testdata/logs/wiki.log.5 +7 -0
- data/test/testdata/logs/wiki.log.6 +5 -0
- data/test/testdata/logs/wiki.log.7 +118 -0
- data/test/testdata/logs/wiki.log.8 +12 -0
- data/test/testdata/site/html/Xpday/rss.xml +53 -103
- data/test/testdata/texts/Bugs/FrontPage.txt +6 -0
- data/test/testdata/texts/Bugs/NoHidden.spam +17850 -0
- data/test/testdata/texts/Bugs/PairProgrammingParties.spam +102 -0
- data/test/testdata/texts/Bugs/PairProgrammingParties.txt +99 -0
- metadata +53 -7
- data/test/TestMail.rb +0 -29
- data/test/gc.log +0 -2
data/bin/Wiki2Go_make_site.rb
CHANGED
data/bin/Wiki2Go_update_site.rb
CHANGED
data/lib/Web2Go/CGIRequest.rb
CHANGED
@@ -75,9 +75,15 @@ module Web2Go
|
|
75
75
|
@cgi.query_string
|
76
76
|
end
|
77
77
|
|
78
|
-
def authenticated
|
78
|
+
def authenticated?
|
79
79
|
!@cgi.auth_type.nil? && !@cgi.auth_type.empty?
|
80
|
-
|
80
|
+
end
|
81
|
+
|
82
|
+
alias :authenticated :authenticated?
|
83
|
+
|
84
|
+
def request_method
|
85
|
+
@cgi.request_method
|
86
|
+
end
|
81
87
|
|
82
88
|
def parameter(name,default_value=nil)
|
83
89
|
value = @params[name]
|
data/lib/Web2Go/CGIResponse.rb
CHANGED
@@ -10,6 +10,7 @@ module Web2Go
|
|
10
10
|
@cgi = cgi
|
11
11
|
@content_type = 'text/html'
|
12
12
|
@redirect = nil
|
13
|
+
@cookies = Hash.new
|
13
14
|
end
|
14
15
|
|
15
16
|
def redirect_to=(redirect_url)
|
@@ -20,27 +21,36 @@ module Web2Go
|
|
20
21
|
options = Hash.new
|
21
22
|
options['type'] = @content_type
|
22
23
|
|
23
|
-
if @
|
24
|
-
options['cookie'] = @
|
24
|
+
if @cookies.length > 0 then
|
25
|
+
options['cookie'] = @cookies
|
25
26
|
end
|
26
27
|
if !@redirect.nil? then
|
27
28
|
options['Status'] = '302 Moved'
|
28
|
-
options[
|
29
|
+
options['location'] = @redirect
|
29
30
|
end
|
30
|
-
|
31
|
-
|
31
|
+
|
32
32
|
@cgi.out(options) do
|
33
33
|
content
|
34
34
|
end
|
35
35
|
|
36
36
|
end
|
37
37
|
|
38
|
+
def failed
|
39
|
+
options = Hash.new
|
40
|
+
options['type'] = @content_type
|
41
|
+
options['Status'] = '404 Not Found'
|
42
|
+
@cgi.out(options) do
|
43
|
+
""
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
38
47
|
def set_cookie(cookie)
|
39
|
-
@
|
48
|
+
@cookies.delete(cookie.name)
|
49
|
+
@cookies[cookie.name] = cookie
|
40
50
|
end
|
41
51
|
|
42
52
|
def cookies
|
43
|
-
@
|
53
|
+
@cookies
|
44
54
|
end
|
45
55
|
|
46
56
|
def add_cookie(name,value,domain=nil,path=nil,expires=nil)
|
@@ -51,13 +61,6 @@ module Web2Go
|
|
51
61
|
set_cookie(cookie)
|
52
62
|
end
|
53
63
|
|
54
|
-
def add_cookies(cookies)
|
55
|
-
# cookies.each do |cookie|
|
56
|
-
# set_cookie(cookie)
|
57
|
-
# end
|
58
|
-
end
|
59
|
-
|
60
|
-
|
61
64
|
end
|
62
65
|
end
|
63
66
|
|
data/lib/Web2Go/MockRequest.rb
CHANGED
@@ -26,9 +26,9 @@ module Web2Go
|
|
26
26
|
#Request interface
|
27
27
|
attr_reader :params
|
28
28
|
attr_accessor :user
|
29
|
-
attr_accessor :authenticated
|
30
29
|
attr_accessor :cookies
|
31
30
|
attr_reader :server_variable
|
31
|
+
attr_accessor :request_method
|
32
32
|
|
33
33
|
def initialize(url = 'http://localhost/',env=ENV)
|
34
34
|
@server_variable = get_server_variables(url)
|
@@ -39,6 +39,7 @@ module Web2Go
|
|
39
39
|
@authenticated = env.has_key?('AUTH_TYPE')
|
40
40
|
@uploaded_files = {}
|
41
41
|
@cookies = {}
|
42
|
+
@request_method = env['REQUEST_METHOD'] || 'GET'
|
42
43
|
end
|
43
44
|
|
44
45
|
def script_name
|
@@ -61,10 +62,19 @@ module Web2Go
|
|
61
62
|
@server_variable['QUERY_STRING']
|
62
63
|
end
|
63
64
|
|
65
|
+
def authenticated?
|
66
|
+
@authenticated
|
67
|
+
end
|
68
|
+
|
69
|
+
alias :authenticated :authenticated?
|
70
|
+
|
71
|
+
def authenticated=(on)
|
72
|
+
@authenticated = on
|
73
|
+
end
|
64
74
|
|
65
75
|
def parameter(name,default_value=nil)
|
66
76
|
value = @params[name]
|
67
|
-
if value.nil? then
|
77
|
+
if value.nil? || value.length ==0 then
|
68
78
|
return default_value
|
69
79
|
else
|
70
80
|
return value[0]
|
data/lib/Web2Go/MockResponse.rb
CHANGED
@@ -9,11 +9,12 @@ module Web2Go
|
|
9
9
|
attr_accessor :body
|
10
10
|
attr_accessor :content_type
|
11
11
|
attr_accessor :redirect_to
|
12
|
-
attr_accessor
|
12
|
+
attr_accessor :cookies
|
13
13
|
|
14
14
|
def initialize
|
15
15
|
@content_type = 'text/html'
|
16
16
|
@cookies = { }
|
17
|
+
@failed = false
|
17
18
|
end
|
18
19
|
|
19
20
|
def set_cookie(cookie)
|
@@ -23,13 +24,15 @@ module Web2Go
|
|
23
24
|
def add_cookie(name,value,domain=nil,path=nil,expires=nil)
|
24
25
|
@cookies[name] = MockCookie.new(name,value,domain,expires)
|
25
26
|
end
|
26
|
-
|
27
|
-
def
|
28
|
-
|
29
|
-
set_cookie(cookie)
|
30
|
-
end
|
27
|
+
|
28
|
+
def failed
|
29
|
+
@failed = true
|
31
30
|
end
|
32
|
-
|
31
|
+
|
32
|
+
def failed?
|
33
|
+
@failed
|
34
|
+
end
|
35
|
+
|
33
36
|
end
|
34
37
|
|
35
38
|
end
|
@@ -2,126 +2,131 @@ require 'webrick/httputils'
|
|
2
2
|
|
3
3
|
module Web2Go
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
class WebrickFile
|
6
|
+
def initialize(file)
|
7
|
+
@file = file
|
8
|
+
end
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
def filename
|
11
|
+
@file.filename
|
12
|
+
end
|
13
|
+
|
14
|
+
def content
|
15
|
+
@file.list[0]
|
16
|
+
end
|
13
17
|
|
14
|
-
def content
|
15
|
-
@file.list[0]
|
16
18
|
end
|
17
19
|
|
18
|
-
|
20
|
+
class WebrickRequest
|
19
21
|
|
20
|
-
|
22
|
+
attr_reader :server_variable
|
23
|
+
attr_reader :params
|
24
|
+
attr_reader :user
|
21
25
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
+
def initialize(request)
|
27
|
+
@request = request
|
28
|
+
@server_variable = request.meta_vars
|
29
|
+
@server_variable['SCRIPT_NAME'], @server_variable['PATH_INFO'] = split_script_and_path(clean(request.path))
|
30
|
+
find_user(request)
|
31
|
+
@params = parse_parameters
|
32
|
+
end
|
26
33
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
@server_variable['SCRIPT_NAME'], @server_variable['PATH_INFO'] = split_script_and_path(clean(request.path))
|
31
|
-
find_user(request)
|
32
|
-
@params = parse_parameters
|
33
|
-
end
|
34
|
+
def script_name
|
35
|
+
@server_variable['SCRIPT_NAME']
|
36
|
+
end
|
34
37
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
def path
|
40
|
-
@server_variable['PATH_INFO']
|
41
|
-
end
|
38
|
+
def path
|
39
|
+
@server_variable['PATH_INFO']
|
40
|
+
end
|
42
41
|
|
43
|
-
|
44
|
-
|
45
|
-
|
42
|
+
def host
|
43
|
+
@request.host
|
44
|
+
end
|
46
45
|
|
47
|
-
|
48
|
-
|
49
|
-
|
46
|
+
def port
|
47
|
+
@request.port
|
48
|
+
end
|
50
49
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
50
|
+
def authenticated?
|
51
|
+
@authenticated
|
52
|
+
end
|
53
|
+
|
54
|
+
alias :authenticated :authenticated?
|
55
|
+
|
56
|
+
def parameter(name,default_value=nil)
|
57
|
+
value = @params[name]
|
58
|
+
if value.nil? then
|
59
|
+
return default_value
|
60
|
+
else
|
61
|
+
return value[0]
|
62
|
+
end
|
63
|
+
end
|
59
64
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
65
|
+
def uploaded_file(name,pos=0)
|
66
|
+
file = @request.query[name]
|
67
|
+
if !file.nil? then
|
68
|
+
return WebrickFile.new(file)
|
69
|
+
end
|
70
|
+
nil
|
71
|
+
end
|
67
72
|
|
68
73
|
|
69
|
-
|
70
|
-
|
71
|
-
|
74
|
+
def cookie(name)
|
75
|
+
return @request.cookies.find { |cookie| cookie.name == name }
|
76
|
+
end
|
72
77
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
private
|
78
|
-
|
79
|
-
def find_user(req)
|
80
|
-
@user = ENV['USER'] || ENV['USERNAME']
|
81
|
-
if @user.nil? or @user.length == 0 then
|
82
|
-
@user = req.peeraddr[2]
|
83
|
-
if @user.nil? or @user.length == 0 then
|
84
|
-
@user = req.peeraddr[3]
|
85
|
-
end
|
86
|
-
end
|
87
|
-
@authenticated = true
|
88
|
-
end
|
89
|
-
|
90
|
-
def add_parameters(form,values)
|
91
|
-
values.each { |key,value|
|
92
|
-
if form.has_key?(key)
|
93
|
-
form[key].push(value)
|
94
|
-
else
|
95
|
-
form[key] = [ value ]
|
96
|
-
end
|
97
|
-
}
|
98
|
-
form
|
99
|
-
end
|
78
|
+
def cookies
|
79
|
+
@request.cookies
|
80
|
+
end
|
100
81
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
form
|
105
|
-
end
|
82
|
+
def request_method
|
83
|
+
@request.request_method
|
84
|
+
end
|
106
85
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
86
|
+
private
|
87
|
+
|
88
|
+
def find_user(req)
|
89
|
+
@user = ENV['USER'] || ENV['USERNAME']
|
90
|
+
if @user.nil? or @user.length == 0 then
|
91
|
+
@user = req.peeraddr[2]
|
92
|
+
if @user.nil? or @user.length == 0 then
|
93
|
+
@user = req.peeraddr[3]
|
94
|
+
end
|
95
|
+
end
|
96
|
+
@authenticated = true
|
97
|
+
end
|
98
|
+
|
99
|
+
def parse_parameters
|
100
|
+
form = {}
|
101
|
+
|
102
|
+
@request.query.each { |key,value|
|
103
|
+
if form.has_key?(key)
|
104
|
+
form[key].push(value)
|
105
|
+
else
|
106
|
+
form[key] = [ value ]
|
107
|
+
end
|
108
|
+
}
|
109
|
+
form
|
110
|
+
end
|
114
111
|
|
115
|
-
|
112
|
+
def split_script_and_path(path)
|
113
|
+
if path =~ /\// then
|
114
|
+
path =~ /^([^\/]+)\/(.*)$/
|
115
|
+
return $1,$2
|
116
|
+
else
|
117
|
+
return path,""
|
118
|
+
end
|
116
119
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
120
|
+
end
|
121
|
+
|
122
|
+
def clean(path)
|
123
|
+
if path.nil? then
|
124
|
+
return ""
|
125
|
+
else
|
126
|
+
return path.squeeze('/').gsub(/^\//,'').gsub(/\/$/,'')
|
127
|
+
end
|
128
|
+
end
|
124
129
|
|
125
|
-
|
130
|
+
end
|
126
131
|
|
127
132
|
end
|
@@ -21,6 +21,10 @@ module Web2Go
|
|
21
21
|
@response.set_redirect(WEBrick::HTTPStatus[302],url)
|
22
22
|
end
|
23
23
|
|
24
|
+
def failed
|
25
|
+
@response.set_error(HTTPStatus::RC_NOT_FOUND)
|
26
|
+
end
|
27
|
+
|
24
28
|
def set_cookie(cookie)
|
25
29
|
@response.cookies.delete_if { |item| item.name == cookie.name }
|
26
30
|
@response.cookies.push(cookie)
|
@@ -37,14 +41,6 @@ module Web2Go
|
|
37
41
|
cookie.path = path.nil? ? '/' : path
|
38
42
|
set_cookie(cookie)
|
39
43
|
end
|
40
|
-
|
41
|
-
def add_cookies(cookies)
|
42
|
-
cookies.each do |cookie|
|
43
|
-
set_cookie(cookie)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
44
|
end
|
48
|
-
|
49
45
|
end
|
50
46
|
|