Wiki2Go 1.16.1 → 1.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. data/lib/Web2Go/CGIRequest.rb +40 -8
  2. data/lib/Web2Go/MockRequest.rb +11 -2
  3. data/lib/Web2Go/WebrickRequest.rb +4 -0
  4. data/lib/Wiki2Go/DotGraphics.rb +1 -1
  5. data/lib/Wiki2Go/Install/config/chonqed_blacklist.txt +1537 -13
  6. data/lib/Wiki2Go/Install/config/mime.types.conf +49 -0
  7. data/lib/Wiki2Go/Install/config/passwords +1 -1
  8. data/lib/Wiki2Go/Install/make_repository.rb +3 -2
  9. data/lib/Wiki2Go/Install/make_site.rb +222 -19
  10. data/lib/Wiki2Go/Install/site/error.html +52 -52
  11. data/lib/Wiki2Go/Install/templates/admin_pages/commit_site.txt +5 -1
  12. data/lib/Wiki2Go/Install/templates/admin_pages/edit.txt +8 -2
  13. data/lib/Wiki2Go/Install/templates/admin_pages/editfiles.txt +52 -7
  14. data/lib/Wiki2Go/Install/templates/admin_pages/greylist.txt +6 -3
  15. data/lib/Wiki2Go/Install/templates/admin_pages/passwords.txt +5 -2
  16. data/lib/Wiki2Go/Install/templates/admin_pages/regenerate.txt +4 -1
  17. data/lib/Wiki2Go/Install/templates/admin_pages/removespam.txt +4 -1
  18. data/lib/Wiki2Go/Install/templates/admin_pages/show_log.txt +5 -1
  19. data/lib/Wiki2Go/Install/templates/admin_pages/update_blacklist.txt +4 -1
  20. data/lib/Wiki2Go/Install/templates/admin_pages/update_conflicts.txt +4 -1
  21. data/lib/Wiki2Go/Install/templates/admin_pages/update_site.txt +5 -1
  22. data/lib/Wiki2Go/Install/templates/full_footer.htm +2 -2
  23. data/lib/Wiki2Go/Install/templates/simple_footer.htm +1 -1
  24. data/lib/Wiki2Go/LineFormatter.rb +41 -31
  25. data/lib/Wiki2Go/Web.rb +1 -22
  26. data/lib/Wiki2Go/Wiki2GoServlet.rb +11 -4
  27. data/test/TestFormatter.rb +11 -11
  28. data/test/TestLineFormatter.rb +37 -37
  29. data/test/TestRepositoryMaker.rb +1 -1
  30. data/test/TestWeb.rb +3 -4
  31. data/test/TestWeb2Go.rb +5 -6
  32. data/test/TestWiki2GoServlet.rb +95 -74
  33. data/test/testdata/expected_edit.html +10 -10
  34. data/test/testdata/expected_out.html +22 -22
  35. data/test/testdata/expected_put.html +10 -10
  36. data/test/testdata/expected_save.html +11 -11
  37. data/test/testdata/expected_savehtml.html +11 -11
  38. data/test/testdata/expected_search.html +8 -8
  39. data/test/testdata/expected_upload.html +11 -11
  40. data/test/testdata/expected_view.html +22 -22
  41. metadata +3 -2
@@ -1,5 +1,11 @@
1
1
  require 'cgi'
2
2
 
3
+ class CGI
4
+ def my_env
5
+ env_table
6
+ end
7
+ end
8
+
3
9
  module Web2Go
4
10
 
5
11
  class CGIFile
@@ -17,25 +23,47 @@ module Web2Go
17
23
 
18
24
  class CGIRequest
19
25
 
20
- attr_reader :server_variable
21
26
  attr_reader :params
27
+ attr_reader :server_variable
22
28
 
23
29
  def initialize(cgi)
24
30
  @cgi = cgi
25
- @server_variable = ENV
31
+ @server_variable = cgi.my_env
26
32
  @params = @cgi.params
33
+ @user = nil
34
+ end
35
+
36
+ def script_name
37
+ @cgi.script_name
27
38
  end
28
39
 
29
40
  def path
30
- @server_variable['PATH_INFO']
41
+ @cgi.path_info
31
42
  end
32
43
 
33
44
  def host
34
- @server_variable['SERVER_NAME']
45
+ if @server_variable.has_key?('HTTP_X_FORWARDED_HOST') then
46
+ host = @server_variable['HTTP_X_FORWARDED_HOST']
47
+ else
48
+ host = @cgi.server_name
49
+ end
50
+ if host =~ /^([^:]*):/ then
51
+ host = $1
52
+ end
53
+ host
35
54
  end
36
55
 
37
56
  def port
38
- @server_variable['SERVER_PORT']
57
+ if @server_variable.has_key?('HTTP_X_FORWARDED_HOST') then
58
+ host = @server_variable['HTTP_X_FORWARDED_HOST']
59
+ if host =~ /:(\d+)/ then
60
+ $1
61
+ else
62
+ '80'
63
+ end
64
+ else
65
+ @cgi.server_port
66
+ end
39
67
  end
40
68
 
41
69
  def user
@@ -43,8 +71,12 @@ module Web2Go
43
71
  @user
44
72
  end
45
73
 
74
+ def query_string
75
+ @cgi.query_string
76
+ end
77
+
46
78
  def authenticated
47
- @server_variable.has_key?("AUTH_TYPE")
79
+ !@cgi.auth_type.nil? && !@cgi.auth_type.empty?
48
80
  end
49
81
 
50
82
  def parameter(name,default_value=nil)
@@ -79,9 +111,9 @@ module Web2Go
79
111
  private
80
112
 
81
113
  def find_user
82
- user = @server_variable['REMOTE_USER']
114
+ user = @cgi.remote_user
83
115
  if user.nil? or user.empty? then
84
- user = @server_variable['REMOTE_ADDR']
116
+ user = @cgi.remote_addr
85
117
  begin
86
118
  addr = Resolv.getname(user)
87
119
  if !addr.nil? and !addr.empty? then
@@ -24,23 +24,27 @@ module Web2Go
24
24
  class MockRequest
25
25
 
26
26
  #Request interface
27
- attr_reader :server_variable
28
27
  attr_reader :params
29
28
  attr_accessor :user
30
29
  attr_accessor :authenticated
31
30
  attr_accessor :cookies
31
+ attr_reader :server_variable
32
32
 
33
33
  def initialize(url = 'http://localhost/',env=ENV)
34
34
  @server_variable = get_server_variables(url)
35
35
  @server_variable.update( env)
36
36
 
37
- @params = CGI::parse(server_variable['QUERY_STRING'])
37
+ @params = CGI::parse(@server_variable['QUERY_STRING'])
38
38
  @user = env['REMOTE_USER'] || env['USER'] || env['USERNAME']
39
39
  @authenticated = env.has_key?('AUTH_TYPE')
40
40
  @uploaded_files = {}
41
41
  @cookies = {}
42
42
  end
43
43
 
44
+ def script_name
45
+ @server_variable['SCRIPT_NAME']
46
+ end
47
+
44
48
  def path
45
49
  @server_variable['PATH_INFO']
46
50
  end
@@ -53,6 +57,11 @@ module Web2Go
53
57
  @server_variable['SERVER_PORT']
54
58
  end
55
59
 
60
+ def query_string
61
+ @server_variable['QUERY_STRING']
62
+ end
63
+
64
+
56
65
  def parameter(name,default_value=nil)
57
66
  value = @params[name]
58
67
  if value.nil? then
@@ -32,6 +32,10 @@ module Web2Go
32
32
  @params = parse_parameters
33
33
  end
34
34
 
35
+ def script_name
36
+ @server_variable['SCRIPT_NAME']
37
+ end
38
+
35
39
  def path
36
40
  @server_variable['PATH_INFO']
37
41
  end
@@ -69,7 +69,7 @@ module Wiki2Go
69
69
  def rewrite_url(config,web,formatter,url)
70
70
  if url =~ /:\/\// then
71
71
  if config.redirect_url?(web,url) then
72
- url = web.base_url + formatter.redirect_url(url)
72
+ url = web.base_url.chop + formatter.redirect_url(url)
73
73
  end
74
74
  else
75
75
  url = formatter.absolute_url_of_topic(url)