diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index 075ba1e2..ddd82b32 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -189,7 +189,9 @@ EOL return unless is_post if [:markdownMML, :markdownPNG, :markdown].include?(@web.markup) @tex_content = '' - params.each do |name, p| + # Ruby 1.9.x has ordered hashes; 1.8.x doesn't. So let's just parse the query ourselves. + ordered_params = ActiveSupport::OrderedHash[*request.raw_post.split('&').collect {|k_v| k_v.split('=').each {|x| CGI::unescape(x)}}.flatten] + ordered_params.each do |name, p| if p == 'tex' && @web.has_page?(name) @tex_content << "\\section*\{#{name}\}\n\n".as_utf8 @tex_content << Maruku.new(@web.page(name).content).to_latex @@ -303,11 +305,7 @@ EOL def save render(:status => 404, :text => 'Undefined page name', :layout => 'error') and return if @page_name.nil? - unless (request.post? || Rails.env.test?) - headers['Allow'] = 'POST' - render(:status => 405, :text => 'You must use an HTTP POST', :layout => 'error') - return - end + return unless is_post author_name = params['author'].purify author_name = 'AnonymousCoward' if author_name =~ /^\s*$/ diff --git a/test/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb index f94a11a0..d43b4bcb 100644 --- a/test/functional/wiki_controller_test.rb +++ b/test/functional/wiki_controller_test.rb @@ -1349,7 +1349,8 @@ Page2 contents $\mathbb{01234}$. @wiki.write_page('wiki1', 'Page2', "Page2 contents $\\mathbb{01234}$.\n", Time.now, Author.new('AnotherAuthor', '127.0.0.2'), x_test_renderer) - r = process('tex_list', 'web' => 'wiki1', 'Page2' => 'tex', 'BogusPage'=> 'tex', 'HomePage' => 'tex') + @request.env['RAW_POST_DATA'] = "_form_key=353106ff8c8466727ee5338baaa0640c87c9b0d6&Page2=tex&BogusPage=tex&HomePage=tex&commit=Export" + r = process('tex_list', 'web' => 'wiki1', 'Page2' => 'tex', 'BogusPage'=> 'tex', 'HomePage' => 'tex') assert_response(:success) assert_equal @tex_header1 + "\\usepackage{mathbbol}\n" + @tex_header2 + %q!\section*{Page2}