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.
This commit is contained in:
parent
b9db67073d
commit
aea2c5099f
|
@ -96,7 +96,7 @@ require 'stringsupport'
|
||||||
|
|
||||||
# Performs HTML escaping on text, but keeps linefeeds intact (by replacing them with <br/>)
|
# Performs HTML escaping on text, but keeps linefeeds intact (by replacing them with <br/>)
|
||||||
def escape_preserving_linefeeds(text)
|
def escape_preserving_linefeeds(text)
|
||||||
h(text).gsub(/\n/, '<br/>')
|
h(text).gsub(/\n/, '<br/>').as_utf8
|
||||||
end
|
end
|
||||||
|
|
||||||
def format_date(date, include_time = true)
|
def format_date(date, include_time = true)
|
||||||
|
|
|
@ -108,7 +108,7 @@ class Page < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_param
|
def to_param
|
||||||
name
|
name.as_utf8
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -78,7 +78,7 @@ class WikiReference < ActiveRecord::Base
|
||||||
"AND wiki_references.link_type = '#{REDIRECTED_PAGE}' " +
|
"AND wiki_references.link_type = '#{REDIRECTED_PAGE}' " +
|
||||||
"AND pages.web_id = '#{web.id}'"
|
"AND pages.web_id = '#{web.id}'"
|
||||||
row = connection.select_one(sanitize_sql([query, page_name]))
|
row = connection.select_one(sanitize_sql([query, page_name]))
|
||||||
row['name'] if row
|
row['name'].as_utf8 if row
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.pages_in_category(web, category)
|
def self.pages_in_category(web, category)
|
||||||
|
@ -88,7 +88,7 @@ class WikiReference < ActiveRecord::Base
|
||||||
"WHERE wiki_references.referenced_name = ? " +
|
"WHERE wiki_references.referenced_name = ? " +
|
||||||
"AND wiki_references.link_type = '#{CATEGORY}' " +
|
"AND wiki_references.link_type = '#{CATEGORY}' " +
|
||||||
"AND pages.web_id = '#{web.id}'"
|
"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
|
end
|
||||||
|
|
||||||
def self.list_categories(web)
|
def self.list_categories(web)
|
||||||
|
|
Loading…
Reference in a new issue