From: Jean-Philippe Lang Date: Mon, 13 Aug 2012 19:36:00 +0000 (+0000) Subject: Fixed: Can't use non-latin anchor in wiki (#11577). X-Git-Tag: 2.1.0~126 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3673fbd881c0a851d070a0ae5015cd6300784c47;p=redmine.git Fixed: Can't use non-latin anchor in wiki (#11577). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10206 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c756168d1..68eeea6db 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1157,7 +1157,12 @@ module ApplicationHelper end def sanitize_anchor_name(anchor) - anchor.gsub(%r{[^\w\s\-]}, '').gsub(%r{\s+(\-+\s*)?}, '-') + if ''.respond_to?(:encoding) + anchor.gsub(%r{[^\p{Word}\s\-]}, '').gsub(%r{\s+(\-+\s*)?}, '-') + else + # TODO: remove when ruby1.8 is no longer supported + anchor.gsub(%r{[^\w\s\-]}, '').gsub(%r{\s+(\-+\s*)?}, '-') + end end # Returns the javascript tags that are included in the html layout head diff --git a/test/unit/helpers/application_helper_test.rb b/test/unit/helpers/application_helper_test.rb index 1ef2ff0f7..f4e116c89 100644 --- a/test/unit/helpers/application_helper_test.rb +++ b/test/unit/helpers/application_helper_test.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 +# # Redmine - project management software # Copyright (C) 2006-2012 Jean-Philippe Lang # @@ -526,6 +528,8 @@ RAW # link with anchor '[[CookBook documentation#One-section]]' => 'CookBook documentation', '[[Another page#anchor|Page]]' => 'Page', + # UTF8 anchor + '[[Another_page#Тест|Тест]]' => %|Тест|, # page that doesn't exist '[[Unknown page]]' => 'Unknown page', '[[Unknown page|404]]' => '404',