]> git.openstreetmap.org Git - rails.git/blobdiff - app/helpers/application_helper.rb
Make rel=nofollow actually work - when in doubt trust the source as
[rails.git] / app / helpers / application_helper.rb
index bee4f9ce2f4dc5a6ec30ab8fb90b816675da3860..2eebec1708378663a5bc4f67ad828ec5dd847da9 100644 (file)
@@ -1,6 +1,14 @@
 module ApplicationHelper
   def htmlize(text)
-    return sanitize(auto_link(simple_format(text), :urls))
+    return sanitize(auto_link(simple_format(text), :link => :urls, :html => { :rel => "nofollow" }))
+  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)