]> source.dussan.org Git - redmine.git/commitdiff
Fixed: Can't use non-latin anchor in wiki (#11577).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 13 Aug 2012 19:36:00 +0000 (19:36 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 13 Aug 2012 19:36:00 +0000 (19:36 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10206 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/application_helper.rb
test/unit/helpers/application_helper_test.rb

index c756168d1153e059157fb2179c331e275be2eab1..68eeea6dbf45205439b049c91b46da87abd0e97f 100644 (file)
@@ -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
index 1ef2ff0f757883308358eac988b1b950f7251c6e..f4e116c898996f958b8c69caeb9284a8a69a4ee1 100644 (file)
@@ -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]]' => '<a href="/projects/ecookbook/wiki/CookBook_documentation#One-section" class="wiki-page">CookBook documentation</a>',
       '[[Another page#anchor|Page]]' => '<a href="/projects/ecookbook/wiki/Another_page#anchor" class="wiki-page">Page</a>',
+      # UTF8 anchor
+      '[[Another_page#Тест|Тест]]' => %|<a href="/projects/ecookbook/wiki/Another_page##{CGI.escape 'Тест'}" class="wiki-page">Тест</a>|,
       # page that doesn't exist
       '[[Unknown page]]' => '<a href="/projects/ecookbook/wiki/Unknown_page" class="wiki-page new">Unknown page</a>',
       '[[Unknown page|404]]' => '<a href="/projects/ecookbook/wiki/Unknown_page" class="wiki-page new">404</a>',