]> git.openstreetmap.org Git - rails.git/blobdiff - app/helpers/application_helper.rb
Make linkify preserve HTML safety
[rails.git] / app / helpers / application_helper.rb
index e285215b8d85a01c81bc7eabb93d58ba233ff774..b77ac87215351fac98b7198179db05d9c4003e9d 100644 (file)
@@ -6,15 +6,27 @@ module ApplicationHelper
   end
 
   def htmlize(text)
-    return linkify(sanitize(simple_format(text)))
+    logger.info "text safety is #{text.html_safe?}"
+    r = simple_format(text)
+    logger.info "formatted text safety is #{r.html_safe?}"
+    r = sanitize(r)
+    logger.info "sanitised text safety is #{r.html_safe?}"
+    r = linkify(r)
+    logger.info "linkified text safety is #{r.html_safe?}"
+    return r
+#    return linkify(sanitize(simple_format(text)))
   end
 
   def linkify(text)
-    return auto_link(text, :link => :urls, :html => { :rel => "nofollow" })
+    if text.html_safe?
+      Rinku.auto_link(text, :urls, tag_options(:rel => "nofollow")).html_safe
+    else
+      Rinku.auto_link(text, :urls, tag_options(:rel => "nofollow"))
+    end
   end
 
   def html_escape_unicode(text)
-    chars = ActiveSupport::Multibyte::Chars.u_unpack(text).map do |c|
+    chars = ActiveSupport::Multibyte::Unicode.u_unpack(text).map do |c|
       c < 127 ? c.chr : "&##{c.to_s};"
     end