]> git.openstreetmap.org Git - rails.git/commitdiff
Escape non-ascii characters in exported HTML. Closes #2075.
authorTom Hughes <tom@compton.nu>
Tue, 27 Oct 2009 00:59:38 +0000 (00:59 +0000)
committerTom Hughes <tom@compton.nu>
Tue, 27 Oct 2009 00:59:38 +0000 (00:59 +0000)
app/helpers/application_helper.rb
app/views/export/start.rjs

index bee4f9ce2f4dc5a6ec30ab8fb90b816675da3860..ab0ba82a830f0440dee2273edb2bf2bf9f34febc 100644 (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
index c146e236d948302e889f997a45f1398cbbc5da1d..3c672204459f5fc0681a69a4e30609ed41658415 100644 (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;