From aea2c5099f8e4849cc1b46716187ace58bee945b Mon Sep 17 00:00:00 2001 From: Jacques Distler Date: Sun, 24 Jan 2010 12:23:47 -0600 Subject: [PATCH] More Ruby 1.9 Encoding Fun Under Ruby 1.9, could not delete orphan pages with utf-8 names. They would be listed as orphan, but "Delete Orphan Pages" would silently not delete them. Fixed. --- app/helpers/application_helper.rb | 2 +- app/models/page.rb | 2 +- app/models/wiki_reference.rb | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 62ce7a22..1727b2cb 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -96,7 +96,7 @@ require 'stringsupport' # Performs HTML escaping on text, but keeps linefeeds intact (by replacing them with
) def escape_preserving_linefeeds(text) - h(text).gsub(/\n/, '
') + h(text).gsub(/\n/, '
').as_utf8 end def format_date(date, include_time = true) diff --git a/app/models/page.rb b/app/models/page.rb index 28ed497a..2ce6feb3 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -108,7 +108,7 @@ class Page < ActiveRecord::Base end def to_param - name + name.as_utf8 end private diff --git a/app/models/wiki_reference.rb b/app/models/wiki_reference.rb index cbc7bcd8..82ef95dc 100644 --- a/app/models/wiki_reference.rb +++ b/app/models/wiki_reference.rb @@ -78,7 +78,7 @@ class WikiReference < ActiveRecord::Base "AND wiki_references.link_type = '#{REDIRECTED_PAGE}' " + "AND pages.web_id = '#{web.id}'" row = connection.select_one(sanitize_sql([query, page_name])) - row['name'] if row + row['name'].as_utf8 if row end def self.pages_in_category(web, category) @@ -88,7 +88,7 @@ class WikiReference < ActiveRecord::Base "WHERE wiki_references.referenced_name = ? " + "AND wiki_references.link_type = '#{CATEGORY}' " + "AND pages.web_id = '#{web.id}'" - names = connection.select_all(sanitize_sql([query, category])).map { |row| row['name'] } + names = connection.select_all(sanitize_sql([query, category])).map { |row| row['name'].as_utf8 } end def self.list_categories(web)