[Rt-commit] rt branch, 4.2/reply-to-html, updated. rt-4.2.1-8-gee1418b

Alex Vandiver alexmv at bestpractical.com
Thu Nov 21 11:38:37 EST 2013


The branch, 4.2/reply-to-html has been updated
       via  ee1418b9efa5c589aa99249fb026ce52f9668d3a (commit)
      from  6eef6f9fe661434e7ea6810ead8ddd9205f8fec4 (commit)

Summary of changes:
 lib/RT/Transaction.pm | 12 ++++++++++++
 1 file changed, 12 insertions(+)

- Log -----------------------------------------------------------------
commit ee1418b9efa5c589aa99249fb026ce52f9668d3a
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Thu Nov 21 11:31:43 2013 -0500

    Trim HTML in replies to the contents of the <body> tag
    
    Email clients vary as to if they attempt to provide a full HTML document
    (starting with doctype and <html>), or merely an HTML-formatted snippet.
    Content which contains an <html> tag unfortunately interacts poorly with
    CKEditor when shoved inside a <blockquote>, effectively imediately
    closing the blockquote.
    
    Pass content to quote through an HTML scrubber to remove the offending
    <html> tags, the <head> tag, and and any <meta> contents thereof.

diff --git a/lib/RT/Transaction.pm b/lib/RT/Transaction.pm
index 2e79e1a..315ea6e 100644
--- a/lib/RT/Transaction.pm
+++ b/lib/RT/Transaction.pm
@@ -347,6 +347,18 @@ sub Content {
 
             if ($args{Type} ne 'text/html') {
                 $content = RT::Interface::Email::ConvertHTMLToText($content);
+            } else {
+                # Scrub out <html>, <head>, <meta>, and <body>, and
+                # leave all else untouched.
+                my $scrubber = HTML::Scrubber->new();
+                $scrubber->rules(
+                    html => 0,
+                    head => 0,
+                    meta => 0,
+                    body => 0,
+                );
+                $scrubber->default( 1 => { '*' => 1 } );
+                $content = $scrubber->scrub( $content );
             }
         }
         else {

-----------------------------------------------------------------------


More information about the rt-commit mailing list