mirror of
https://github.com/redmine/redmine.git
synced 2025-11-08 06:15:59 +01:00
Patch by Pavel Rosický. git-svn-id: http://svn.redmine.org/redmine/trunk@20892 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -692,7 +692,7 @@ class ApplicationController < ActionController::Base
|
|||||||
|
|
||||||
# Returns a string that can be used as filename value in Content-Disposition header
|
# Returns a string that can be used as filename value in Content-Disposition header
|
||||||
def filename_for_content_disposition(name)
|
def filename_for_content_disposition(name)
|
||||||
%r{(MSIE|Trident|Edge)}.match?(request.env['HTTP_USER_AGENT'].to_s) ? ERB::Util.url_encode(name) : name
|
name
|
||||||
end
|
end
|
||||||
|
|
||||||
def api_request?
|
def api_request?
|
||||||
|
|||||||
@@ -1152,7 +1152,7 @@ class WikiControllerTest < Redmine::ControllerTest
|
|||||||
assert_include 'h1. CookBook documentation v2', @response.body
|
assert_include 'h1. CookBook documentation v2', @response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show_filename_should_be_uri_encoded_for_ms_browsers
|
def test_show_filename_should_be_uri_encoded
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
title = 'Этика_менеджмента'
|
title = 'Этика_менеджмента'
|
||||||
%w|pdf html txt|.each do |format|
|
%w|pdf html txt|.each do |format|
|
||||||
@@ -1160,14 +1160,15 @@ class WikiControllerTest < Redmine::ControllerTest
|
|||||||
@request.user_agent = ""
|
@request.user_agent = ""
|
||||||
get :show, :params => {:project_id => 1, :id => title, :format => format}
|
get :show, :params => {:project_id => 1, :id => title, :format => format}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal "attachment; filename=\"#{title}.#{format}\"",
|
ascii_filename = "%3F%3F%3F%3F%3F_%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F.#{format}"
|
||||||
|
utf8_filename = "%D0%AD%D1%82%D0%B8%D0%BA%D0%B0_%D0%BC%D0%B5%D0%BD%D0%B5%D0%B4%D0%B6%D0%BC%D0%B5%D0%BD%D1%82%D0%B0.#{format}"
|
||||||
|
assert_equal "attachment; filename=\"#{ascii_filename}\"; filename*=UTF-8''#{utf8_filename}",
|
||||||
@response.headers['Content-Disposition']
|
@response.headers['Content-Disposition']
|
||||||
# Microsoft's browsers: filename should be URI encoded
|
# Microsoft's browsers
|
||||||
@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'
|
@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}
|
get :show, :params => {:project_id => 1, :id => title, :format => format}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
filename = Addressable::URI.encode("#{title}.#{format}")
|
assert_equal "attachment; filename=\"#{ascii_filename}\"; filename*=UTF-8''#{utf8_filename}",
|
||||||
assert_equal "attachment; filename=\"#{filename}\"",
|
|
||||||
@response.headers['Content-Disposition']
|
@response.headers['Content-Disposition']
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user