diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index c756168..68eeea6 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 1ef2ff0..f4e116c 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',