summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJean-Baptiste Barth <jeanbaptiste.barth@gmail.com>2013-05-06 22:19:37 +0000
committerJean-Baptiste Barth <jeanbaptiste.barth@gmail.com>2013-05-06 22:19:37 +0000
commitb4c3bb0558654e6926bf0203414602bfa1818c9f (patch)
tree9fa821f6caf6bbc1230469b784f1a411d782dd05 /lib
parent2b3111122e0a138b282cdc478e341c0774ad19ae (diff)
downloadredmine-b4c3bb0558654e6926bf0203414602bfa1818c9f.tar.gz
redmine-b4c3bb0558654e6926bf0203414602bfa1818c9f.zip
Fix Trac importer breaking on exotic characters with ruby 1.9+ (#13990).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11796 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib')
-rw-r--r--lib/tasks/migrate_from_trac.rake6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/tasks/migrate_from_trac.rake b/lib/tasks/migrate_from_trac.rake
index 406a5b221..ddc77fb34 100644
--- a/lib/tasks/migrate_from_trac.rake
+++ b/lib/tasks/migrate_from_trac.rake
@@ -153,7 +153,11 @@ namespace :redmine do
private
def trac_fullpath
attachment_type = read_attribute(:type)
- trac_file = filename.gsub( /[^a-zA-Z0-9\-_\.!~*']/n ) {|x| sprintf('%%%02x', x[0]) }
+ #replace exotic characters with their hex representation to avoid invalid filenames
+ trac_file = filename.gsub( /[^a-zA-Z0-9\-_\.!~*']/n ) do |x|
+ codepoint = RUBY_VERSION < '1.9' ? x[0] : x.codepoints.to_a[0]
+ sprintf('%%%02x', codepoint)
+ end
"#{TracMigrate.trac_attachments_directory}/#{attachment_type}/#{id}/#{trac_file}"
end
end