Merged r16957 from trunk to 3.3-stable (#26599)

fix file name corruption when export a wiki page with non-ASCII title in MS browsers.

Contributed by Go MAEDA.

git-svn-id: http://svn.redmine.org/redmine/branches/3.3-stable@16960 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA
2017-08-30 16:39:41 +00:00
parent 2ede29186c
commit 995a0111e9
2 changed files with 25 additions and 3 deletions

View File

@@ -1,3 +1,5 @@
# encoding: utf-8
#
# Redmine - project management software
# Copyright (C) 2006-2016 Jean-Philippe Lang
#
@@ -989,6 +991,26 @@ class WikiControllerTest < ActionController::TestCase
assert_include 'h1. CookBook documentation', @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, :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, :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