From 9d0eceeef5313a015045afb900ab4c9ab2bf1627 Mon Sep 17 00:00:00 2001 From: MAEDA Go Date: Tue, 1 Aug 2017 21:01:55 +0900 Subject: [PATCH 2/2] Add a test for file name corruption when export a wiki page with Non-ASCII title in MS browsers. --- test/functional/wiki_controller_test.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb index 314d46385..a558b8014 100644 --- a/test/functional/wiki_controller_test.rb +++ b/test/functional/wiki_controller_test.rb @@ -1087,6 +1087,24 @@ 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 = 'Этика_менеджмента' + + # Non-MS browsers + get :show, :params => {:project_id => 1, :id => title, :format => 'txt'} + assert_response :success + assert_equal "attachment; filename=\"#{title + '.txt'}\"", + @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 => 'txt'} + assert_response :success + assert_equal "attachment; filename=\"#{URI.encode(title + '.txt')}\"", + @response.headers['Content-Disposition'] + end + def test_edit_unprotected_page # Non members can edit unprotected wiki pages @request.session[:user_id] = 4 -- 2.11.0 (Apple Git-81)