mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-19 15:01:14 +00:00
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
This commit is contained in:
parent
1aa08f9c0e
commit
0f6fd7584b
@ -100,14 +100,14 @@ class WikiController < ApplicationController
|
|||||||
|
|
||||||
if User.current.allowed_to?(:export_wiki_pages, @project)
|
if User.current.allowed_to?(:export_wiki_pages, @project)
|
||||||
if params[:format] == 'pdf'
|
if params[:format] == 'pdf'
|
||||||
send_file_headers! :type => 'application/pdf', :filename => "#{@page.title}.pdf"
|
send_file_headers! :type => 'application/pdf', :filename => filename_for_content_disposition("#{@page.title}.pdf")
|
||||||
return
|
return
|
||||||
elsif params[:format] == 'html'
|
elsif params[:format] == 'html'
|
||||||
export = render_to_string :action => 'export', :layout => false
|
export = render_to_string :action => 'export', :layout => false
|
||||||
send_data(export, :type => 'text/html', :filename => "#{@page.title}.html")
|
send_data(export, :type => 'text/html', :filename => filename_for_content_disposition("#{@page.title}.html"))
|
||||||
return
|
return
|
||||||
elsif params[:format] == 'txt'
|
elsif params[:format] == 'txt'
|
||||||
send_data(@content.text, :type => 'text/plain', :filename => "#{@page.title}.txt")
|
send_data(@content.text, :type => 'text/plain', :filename => filename_for_content_disposition("#{@page.title}.txt"))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
# encoding: utf-8
|
||||||
|
#
|
||||||
# Redmine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
@ -1087,6 +1089,26 @@ 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
|
||||||
|
@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
|
def test_edit_unprotected_page
|
||||||
# Non members can edit unprotected wiki pages
|
# Non members can edit unprotected wiki pages
|
||||||
@request.session[:user_id] = 4
|
@request.session[:user_id] = 4
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user