summaryrefslogtreecommitdiffstats
path: root/test/functional
diff options
context:
space:
mode:
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>2017-08-30 15:46:45 +0000
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>2017-08-30 15:46:45 +0000
commit0f6fd7584b11d1f098f5b945c30651d1b078c1de (patch)
treeb8f393546328873d32e0ad5ba528b810a843ac0c /test/functional
parent1aa08f9c0efe73af6ecac7f0e443c25549cfbb65 (diff)
downloadredmine-0f6fd7584b11d1f098f5b945c30651d1b078c1de.tar.gz
redmine-0f6fd7584b11d1f098f5b945c30651d1b078c1de.zip
fix file name corruption when export a wiki page with non-ASCII title in MS browsers (#26599)
Contributed by Go MAEDA. git-svn-id: http://svn.redmine.org/redmine/trunk@16957 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/functional')
-rw-r--r--test/functional/wiki_controller_test.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb
index 314d46385..193efb0b7 100644
--- a/test/functional/wiki_controller_test.rb
+++ b/test/functional/wiki_controller_test.rb
@@ -1,3 +1,5 @@
+# encoding: utf-8
+#
# Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang
#
@@ -1087,6 +1089,26 @@ class WikiControllerTest < Redmine::ControllerTest
assert_include 'h1. CookBook documentation v2', @response.body
end
+ def test_show_filename_should_be_uri_encoded_for_ms_browsers
+ @request.session[:user_id] = 2
+ title = 'Этика_менеджмента'
+ %w|pdf html txt|.each do |format|
+ # Non-MS browsers
+ @request.user_agent = ""
+ get :show, :params => {:project_id => 1, :id => title, :format => format}
+ assert_response :success
+ assert_equal "attachment; filename=\"#{title}.#{format}\"",
+ @response.headers['Content-Disposition']
+ # Microsoft's browsers: filename should be URI encoded
+ @request.user_agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36 Edge/15.15063'
+ get :show, :params => {:project_id => 1, :id => title, :format => format}
+ assert_response :success
+ filename = URI.encode("#{title}.#{format}")
+ assert_equal "attachment; filename=\"#{filename}\"",
+ @response.headers['Content-Disposition']
+ end
+ end
+
def test_edit_unprotected_page
# Non members can edit unprotected wiki pages
@request.session[:user_id] = 4