Wiki2Go 1.17.5 → 1.22.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. data/bin/Wiki2Go_firewall_blacklist.rb +8 -0
  2. data/bin/Wiki2Go_make_cvs_repository.rb +1 -0
  3. data/bin/Wiki2Go_make_site.rb +1 -2
  4. data/bin/Wiki2Go_update_site.rb +1 -2
  5. data/lib/Web2Go/CGIRequest.rb +8 -2
  6. data/lib/Web2Go/CGIResponse.rb +17 -14
  7. data/lib/Web2Go/MockRequest.rb +12 -2
  8. data/lib/Web2Go/MockResponse.rb +10 -7
  9. data/lib/Web2Go/WebrickRequest.rb +106 -101
  10. data/lib/Web2Go/WebrickResponse.rb +4 -8
  11. data/lib/Wiki2Go/BlackList.rb +48 -25
  12. data/lib/Wiki2Go/DotGraphics.rb +1 -1
  13. data/lib/Wiki2Go/FileStorage.rb +266 -266
  14. data/lib/Wiki2Go/HTMLFormatter.rb +28 -0
  15. data/lib/Wiki2Go/Install/config/chonqed_blacklist.txt +418 -0
  16. data/lib/Wiki2Go/Install/config/passwords +1 -1
  17. data/lib/Wiki2Go/Install/config/url_blacklist.txt +3855 -0
  18. data/lib/Wiki2Go/Install/make_repository.rb +32 -26
  19. data/lib/Wiki2Go/Install/make_site.rb +197 -111
  20. data/lib/Wiki2Go/Install/site/error.html +1 -1
  21. data/lib/Wiki2Go/Install/site/robots.txt +10 -1
  22. data/lib/Wiki2Go/Install/site/style.css +129 -64
  23. data/lib/Wiki2Go/Install/templates/admin.htm +1 -1
  24. data/lib/Wiki2Go/Install/templates/admin_pages/edit.txt +2 -1
  25. data/lib/Wiki2Go/Install/templates/admin_pages/format_for_fck.txt +31 -0
  26. data/lib/Wiki2Go/Install/templates/admin_pages/passwords.txt +1 -1
  27. data/lib/Wiki2Go/Install/templates/edit.htm +62 -46
  28. data/lib/Wiki2Go/Install/templates/full_footer.htm +31 -33
  29. data/lib/Wiki2Go/Install/templates/header.htm +0 -1
  30. data/lib/Wiki2Go/Install/templates/menu.htm +29 -0
  31. data/lib/Wiki2Go/Install/templates/pagelist.htm +46 -43
  32. data/lib/Wiki2Go/Install/templates/simple_footer.htm +20 -16
  33. data/lib/Wiki2Go/Install/templates/versionlist.htm +52 -40
  34. data/lib/Wiki2Go/Install/templates/view.htm +46 -29
  35. data/lib/Wiki2Go/Install/templates/wikiedit.htm +63 -0
  36. data/lib/Wiki2Go/Install/wiki/delete.png +0 -0
  37. data/lib/Wiki2Go/Install/wiki/style.css +133 -63
  38. data/lib/Wiki2Go/LineFormatter.rb +345 -197
  39. data/lib/Wiki2Go/Page.rb +16 -3
  40. data/lib/Wiki2Go/PrivateWikiConfig.rb +5 -5
  41. data/lib/Wiki2Go/PublicWikiConfig.rb +83 -37
  42. data/lib/Wiki2Go/ReadWriteWikiConfig.rb +8 -8
  43. data/lib/Wiki2Go/Server.rb +6 -1
  44. data/lib/Wiki2Go/SpamFilter.rb +32 -41
  45. data/lib/Wiki2Go/Web.rb +10 -3
  46. data/lib/Wiki2Go/Wiki2Go.rb +301 -94
  47. data/lib/Wiki2Go/Wiki2GoConfig.rb +87 -6
  48. data/lib/Wiki2Go/Wiki2GoServlet.rb +66 -12
  49. data/lib/Wiki2Go/WikiFormatter.rb +60 -30
  50. data/lib/Wiki2Go/cgi/diff.rb +20 -0
  51. data/lib/Wiki2Go/cgi/secure/log_rss.rb +21 -0
  52. data/lib/Wiki2Go/cgi/sidebyside.rb +20 -0
  53. data/lib/Wiki2Go/cgi/wikiedit.rb +20 -0
  54. data/lib/Wiki2Go/firewall_blacklist.rb +88 -0
  55. data/test/All.rb +5 -2
  56. data/test/TestBlackList.rb +70 -14
  57. data/test/TestConfig.rb +5 -5
  58. data/test/TestDiff.rb +95 -0
  59. data/test/TestFormatter.rb +14 -16
  60. data/test/TestHTMLFormatter.rb +37 -0
  61. data/test/TestInstall.rb +70 -27
  62. data/test/TestLineFormatter.rb +71 -15
  63. data/test/TestRSS.rb +8 -7
  64. data/test/TestRepository.rb +50 -0
  65. data/test/TestServer.rb +3 -8
  66. data/test/TestSpamFilter.rb +33 -1
  67. data/test/TestStorage.rb +11 -0
  68. data/test/TestWeb.rb +2 -2
  69. data/test/TestWiki2Go.rb +766 -166
  70. data/test/TestWiki2GoServlet.rb +1122 -524
  71. data/test/UnitTestFiles.rb +7 -3
  72. data/test/Wiki2GoConfigForTest.rb +40 -6
  73. data/test/checksite.rb +17 -50
  74. data/test/test_firewall_blacklist.rb +131 -0
  75. data/test/test_page.rb +45 -0
  76. data/test/testdata/Registration.rbl.txt +7 -0
  77. data/test/testdata/config/url_blacklist.txt +38822 -0
  78. data/test/testdata/expected_changes.html +1 -2
  79. data/test/testdata/expected_edit.html +108 -59
  80. data/test/testdata/expected_full_rss.xml +2 -2
  81. data/test/testdata/expected_out.html +97 -61
  82. data/test/testdata/expected_put.html +88 -53
  83. data/test/testdata/expected_save.html +88 -52
  84. data/test/testdata/expected_savehtml.html +88 -52
  85. data/test/testdata/expected_search.html +68 -53
  86. data/test/testdata/expected_upload.html +88 -53
  87. data/test/testdata/expected_versions.html +97 -82
  88. data/test/testdata/expected_view.html +97 -61
  89. data/test/testdata/firewall/iptables.config +37 -0
  90. data/test/testdata/firewall/user_blacklist.txt +162 -0
  91. data/test/testdata/logs/wiki.log +652 -0
  92. data/test/testdata/logs/wiki.log.0 +113 -0
  93. data/test/testdata/logs/wiki.log.1 +113 -0
  94. data/test/testdata/logs/wiki.log.2 +113 -0
  95. data/test/testdata/logs/wiki.log.3 +115 -0
  96. data/test/testdata/logs/wiki.log.4 +5 -0
  97. data/test/testdata/logs/wiki.log.5 +7 -0
  98. data/test/testdata/logs/wiki.log.6 +5 -0
  99. data/test/testdata/logs/wiki.log.7 +118 -0
  100. data/test/testdata/logs/wiki.log.8 +12 -0
  101. data/test/testdata/site/html/Xpday/rss.xml +53 -103
  102. data/test/testdata/texts/Bugs/FrontPage.txt +6 -0
  103. data/test/testdata/texts/Bugs/NoHidden.spam +17850 -0
  104. data/test/testdata/texts/Bugs/PairProgrammingParties.spam +102 -0
  105. data/test/testdata/texts/Bugs/PairProgrammingParties.txt +99 -0
  106. metadata +53 -7
  107. data/test/TestMail.rb +0 -29
  108. data/test/gc.log +0 -2
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ gem "Wiki2Go"
5
+
6
+ require 'Wiki2Go/firewall_blacklist.rb'
7
+
8
+ Wiki2Go::FirewallBlacklist.generate(ARGV) { |msg| puts msg }
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'rubygems'
4
+ gem "Wiki2Go"
4
5
 
5
6
  require 'fileutils'
6
7
  require 'Wiki2Go/Install/make_repository'
@@ -3,8 +3,7 @@
3
3
  require 'rubygems'
4
4
  gem "Wiki2Go"
5
5
 
6
- require 'fileutils'
7
6
  require 'Wiki2Go/Install/make_site'
8
7
 
9
- Wiki2Go::Install::make_site(ARGV)
8
+ Wiki2Go::Install::make_site(ARGV) { |msg| puts msg }
10
9
 
@@ -3,8 +3,7 @@
3
3
  require 'rubygems'
4
4
  gem "Wiki2Go"
5
5
 
6
- require 'fileutils'
7
6
  require 'Wiki2Go/Install/make_site'
8
7
 
9
- Wiki2Go::Install::update_site(ARGV)
8
+ Wiki2Go::Install::update_site(ARGV) { |msg| puts msg }
10
9
 
@@ -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
- end
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]
@@ -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 @cgi.cookies.length > 0 then
24
- options['cookie'] = @cgi.cookies
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[ 'location'] = @redirect
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
- @cgi.cookies[cookie.name] = cookie
48
+ @cookies.delete(cookie.name)
49
+ @cookies[cookie.name] = cookie
40
50
  end
41
51
 
42
52
  def cookies
43
- @cgi.cookies
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
 
@@ -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]
@@ -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 :cookies
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 add_cookies(cookies)
28
- cookies.each do |cookie|
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
- class WebrickFile
6
- def initialize(file)
7
- @file = file
8
- end
5
+ class WebrickFile
6
+ def initialize(file)
7
+ @file = file
8
+ end
9
9
 
10
- def filename
11
- @file.filename
12
- end
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
- end
20
+ class WebrickRequest
19
21
 
20
- class WebrickRequest
22
+ attr_reader :server_variable
23
+ attr_reader :params
24
+ attr_reader :user
21
25
 
22
- attr_reader :server_variable
23
- attr_reader :params
24
- attr_reader :user
25
- attr_reader :authenticated
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
- def initialize(request)
28
- @request = request
29
- @server_variable = request.meta_vars
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
- def script_name
36
- @server_variable['SCRIPT_NAME']
37
- end
38
-
39
- def path
40
- @server_variable['PATH_INFO']
41
- end
38
+ def path
39
+ @server_variable['PATH_INFO']
40
+ end
42
41
 
43
- def host
44
- @request.host
45
- end
42
+ def host
43
+ @request.host
44
+ end
46
45
 
47
- def port
48
- @request.port
49
- end
46
+ def port
47
+ @request.port
48
+ end
50
49
 
51
- def parameter(name,default_value=nil)
52
- value = @params[name]
53
- if value.nil? then
54
- return default_value
55
- else
56
- return value[0]
57
- end
58
- end
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
- def uploaded_file(name,pos=0)
61
- file = @request.query[name]
62
- if !file.nil? then
63
- return WebrickFile.new(file)
64
- end
65
- nil
66
- end
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
- def cookie(name)
70
- return @request.cookies.find { |cookie| cookie.name == name }
71
- end
74
+ def cookie(name)
75
+ return @request.cookies.find { |cookie| cookie.name == name }
76
+ end
72
77
 
73
- def cookies
74
- @request.cookies
75
- end
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
- def parse_parameters
102
- form = add_parameters({ },WEBrick::HTTPUtils::parse_query(@request.body))
103
- form = add_parameters(form,WEBrick::HTTPUtils::parse_query(@request.query_string))
104
- form
105
- end
82
+ def request_method
83
+ @request.request_method
84
+ end
106
85
 
107
- def split_script_and_path(path)
108
- if path =~ /\// then
109
- path =~ /^([^\/]+)\/(.*)$/
110
- return $1,$2
111
- else
112
- return path,""
113
- end
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
- end
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
- def clean(path)
118
- if path.nil? then
119
- return ""
120
- else
121
- return path.squeeze('/').gsub(/^\//,'').gsub(/\/$/,'')
122
- end
123
- end
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
- end
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