Escape non-ascii characters in exported HTML. Closes #2075.

This commit is contained in:
Tom Hughes 2009-10-27 00:59:38 +00:00
parent 59a1543ad0
commit e0cbfe24a5
2 changed files with 9 additions and 1 deletions

View file

@ -3,6 +3,14 @@ module ApplicationHelper
return sanitize(auto_link(simple_format(text), :urls))
end
def html_escape_unicode(text)
chars = ActiveSupport::Multibyte::Chars.u_unpack(text).map do |c|
c < 127 ? c.chr : "&##{c.to_s};"
end
return chars.join("")
end
def rss_link_to(*args)
return link_to(image_tag("RSS.gif", :size => "16x16", :border => 0), Hash[*args], { :class => "rsssmall" });
end

View file

@ -248,7 +248,7 @@ page << <<EOJ
var layers = getMapLayers();
html += '<br /><small><a href="http://#{SERVER_URL}/?lat='+center.lat+'&lon='+center.lon+'&zoom='+zoom+'&layers='+layers+markerUrl+'">'+"#{I18n.t('export.start_rjs.view_larger_map')}"+'</a></small>';
html += '<br /><small><a href="http://#{SERVER_URL}/?lat='+center.lat+'&lon='+center.lon+'&zoom='+zoom+'&layers='+layers+markerUrl+'">'+"#{html_escape_unicode(I18n.t('export.start_rjs.view_larger_map'))}"+'</a></small>';
$("export_html_text").value = html;