summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2007-10-05 19:33:25 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2007-10-05 19:33:25 +0000
commit69c296505159fb6fa073d897b517645fd79dfe8a (patch)
tree1caa836a015deea8e70e6f63aca5ecd7b3775739
parente8971e5f831cfaee8fe18508c1fd154af99a96e0 (diff)
downloadredmine-69c296505159fb6fa073d897b517645fd79dfe8a.tar.gz
redmine-69c296505159fb6fa073d897b517645fd79dfe8a.zip
Fixed: Title with non-ascii characters breaks wiki
git-svn-id: http://redmine.rubyforge.org/svn/trunk@805 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/models/wiki.rb2
-rw-r--r--test/unit/wiki_test.rb5
2 files changed, 6 insertions, 1 deletions
diff --git a/app/models/wiki.rb b/app/models/wiki.rb
index 7213efde8..b6d6a9b50 100644
--- a/app/models/wiki.rb
+++ b/app/models/wiki.rb
@@ -48,7 +48,7 @@ class Wiki < ActiveRecord::Base
# replace spaces with _ and remove unwanted caracters
title = title.gsub(/\s+/, '_').delete(',./?;|:') if title
# upcase the first letter
- title = (title.length > 1 ? title.first.upcase + title[1..-1] : title.upcase) if title
+ title = (title.slice(0..0).upcase + (title.slice(1..-1) || '')) if title
title
end
end
diff --git a/test/unit/wiki_test.rb b/test/unit/wiki_test.rb
index a89be2e71..23d4f442c 100644
--- a/test/unit/wiki_test.rb
+++ b/test/unit/wiki_test.rb
@@ -36,4 +36,9 @@ class WikiTest < Test::Unit::TestCase
@wiki.reload
assert_equal "Another start page", @wiki.start_page
end
+
+ def test_titleize
+ assert_equal 'Page_title_with_CAPITALES', Wiki.titleize('page title with CAPITALES')
+ assert_equal 'テスト', Wiki.titleize('テスト')
+ end
end