From 6cf1463525b0f694b8fddd5ad3a2daf051e74f90 Mon Sep 17 00:00:00 2001 From: Jacques Distler Date: Mon, 4 Jan 2010 18:43:27 -0600 Subject: [PATCH] Revert Revision 520; This is more thorough This ensures that @page.name has the right (utf8) encoding. --- app/controllers/wiki_controller.rb | 1 + app/models/author.rb | 2 +- app/models/page.rb | 2 +- test/functional/wiki_controller_test.rb | 4 +++- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index b4d247f2..07bd54e5 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -389,6 +389,7 @@ class WikiController < ApplicationController def load_page @page_name = params['id'] ? params['id'].purify : nil @page = @wiki.read_page(@web_name, @page_name) if @page_name + @page.name.as_utf8 if @page end private diff --git a/app/models/author.rb b/app/models/author.rb index be8a5cf7..a257a01f 100644 --- a/app/models/author.rb +++ b/app/models/author.rb @@ -3,7 +3,7 @@ class Author < String attr_reader :name def initialize(name, ip = nil) @ip = ip - super(name) + super(name.as_utf8) end def name=(value) diff --git a/app/models/page.rb b/app/models/page.rb index e958ccfe..e66e0415 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -82,7 +82,7 @@ class Page < ActiveRecord::Base # Returns the original wiki-word name as separate words, so "MyPage" becomes "My Page". def plain_name - web.brackets_only? ? CGI.escapeHTML(name).as_utf8 : CGI.escapeHTML(WikiWords.separate(name)).as_utf8 + web.brackets_only? ? CGI.escapeHTML(name) : CGI.escapeHTML(WikiWords.separate(name)) end LOCKING_PERIOD = 30.minutes diff --git a/test/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb index e461b015..048bba1f 100644 --- a/test/functional/wiki_controller_test.rb +++ b/test/functional/wiki_controller_test.rb @@ -683,7 +683,9 @@ class WikiControllerTest < ActionController::TestCase assert_match @eternity, r.headers["Set-Cookie"][0] new_page = @wiki.read_page('wiki1', 'NewPage') assert_equal "Double-struck A: \360\235\224\270", new_page.content - assert_equal "\360\235\224\270\303\274thorOfNewPage", new_page.author + a = ''.respond_to?(:force_encoding) ? "\u{1D538}\u00FCthorOfNewPage" : + "\360\235\224\270\303\274thorOfNewPage" + assert_equal a, new_page.author assert_equal "\360\235\224\270\303\274thorOfNewPage", r.cookies['author'] end