[Rt-commit] rt branch, 4.2/reply-to-html, created. rt-4.2.1-7-g6eef6f9

Alex Vandiver alexmv at bestpractical.com
Tue Nov 19 11:52:57 EST 2013


The branch, 4.2/reply-to-html has been created
        at  6eef6f9fe661434e7ea6810ead8ddd9205f8fec4 (commit)

- Log -----------------------------------------------------------------
commit 7260e36086cff16a186c7394659205c7835162bf
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Tue Nov 19 10:15:51 2013 -0500

    Replies with the rich text should quote an HTML part using <blockquote>
    
    The gmail_quote class is semi-standard, and occasionally aids in
    display.

diff --git a/lib/RT/Transaction.pm b/lib/RT/Transaction.pm
index 3b17319..151c7a8 100644
--- a/lib/RT/Transaction.pm
+++ b/lib/RT/Transaction.pm
@@ -367,10 +367,18 @@ sub Content {
     }
 
     if ( $args{'Quote'} ) {
-        $content = $self->ApplyQuoteWrap(content => $content,
-                                         cols    => $args{'Wrap'} );
+        if ($args{Type} eq 'text/html') {
+            $content = '<div class="gmail_quote">'
+                . $self->QuoteHeader
+                . '<br /><blockquote class="gmail_quote" type="cite">'
+                . $content
+                . '</blockquote></div><br /><br />';
+        } else {
+            $content = $self->ApplyQuoteWrap(content => $content,
+                                             cols    => $args{'Wrap'} );
 
-        $content = $self->QuoteHeader . "\n$content\n\n";
+            $content = $self->QuoteHeader . "\n$content\n\n";
+        }
     }
 
     return ($content);
diff --git a/share/html/Elements/MessageBox b/share/html/Elements/MessageBox
index 03f2892..ee61e94 100644
--- a/share/html/Elements/MessageBox
+++ b/share/html/Elements/MessageBox
@@ -50,17 +50,18 @@
 % $m->callback( %ARGS, SignatureRef => \$signature );
 <% $Default || '' %><% $message %><% $signature %></textarea>
 % $m->callback( %ARGS, CallbackName => 'AfterTextArea' );
-% if (RT->Config->Get('MessageBoxRichText',  $session{'CurrentUser'})) {
-<input type="text" style="display:none" name="<% $Name %>Type" id="<% $Name %>Type" value="<% $m->request_args->{$Name."Type"}||'' %>" />
+% if ($type eq 'text/html') {
+<input type="text" style="display:none" name="<% $Name %>Type" id="<% $Name %>Type" value="<% $m->request_args->{$Name."Type"}||$type %>" />
 % }
 <%INIT>
 
+my $type = RT->Config->Get('MessageBoxRichText',  $session{'CurrentUser'}) ? 'text/html' : 'text/plain';
 my $message = '';
 
 if ( $QuoteTransaction ) {
     my $transaction = RT::Transaction->new( $session{'CurrentUser'} );
     $transaction->Load( $QuoteTransaction );
-    $message = $transaction->Content( Quote => 1 );
+    $message = $transaction->Content( Quote => 1, Type  => $type );
 }
 
 my $signature = '';

commit c6ca446c4a4ddf378d306efb1e3dde38a15e9985
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Tue Nov 19 10:16:21 2013 -0500

    Ensure that plaintext signatures are escaped correctly before being appended
    
    We use specific escaping, rather than EscapeHTML, because the
    signature-detection code in RT::Interface::Web::StripContent assumes
    that the signature was transformed into HTML by CKEditor; as such, to
    ensure that no-data messages are detected as before, use the same
    transformations here.

diff --git a/share/html/Elements/MessageBox b/share/html/Elements/MessageBox
index ee61e94..3ec1821 100644
--- a/share/html/Elements/MessageBox
+++ b/share/html/Elements/MessageBox
@@ -67,6 +67,15 @@ if ( $QuoteTransaction ) {
 my $signature = '';
 if ( $IncludeSignature and my $text = $session{'CurrentUser'}->UserObj->Signature ) {
     $signature = "-- \n". $text;
+    if ($type eq 'text/html') {
+        $signature =~ s/&/&/g;
+        $signature =~ s/</</g;
+        $signature =~ s/>/>/g;
+        $signature =~ s/"/"/g;  # "//;
+        $signature =~ s/'/'/g;   # '//;
+        $signature =~ s{\n}{<br />}g;
+        $signature = "<p>$signature</p>";
+    }
 }
 
 # wrap="something" seems to really break IE + richtext

commit 4f69a37cf331f1809e6616b0064fdf47b01556ca
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Tue Nov 19 10:16:39 2013 -0500

    Logic simplification

diff --git a/share/html/Elements/MessageBox b/share/html/Elements/MessageBox
index 3ec1821..fc31050 100644
--- a/share/html/Elements/MessageBox
+++ b/share/html/Elements/MessageBox
@@ -79,10 +79,7 @@ if ( $IncludeSignature and my $text = $session{'CurrentUser'}->UserObj->Signatur
 }
 
 # wrap="something" seems to really break IE + richtext
-my $wrap_type = '';
-if ( not RT->Config->Get('MessageBoxRichText',  $session{'CurrentUser'}) ) {
-    $wrap_type = 'wrap="soft"';
-}
+my $wrap_type = $type eq 'text/html' ? '' : 'wrap="soft"';
 
 # If there's no cols specified, we want to set the width to 100% in CSS
 my $width_attr;

commit c09197e6c64188b25500c8a4a596b699c4dff633
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Tue Nov 19 10:19:04 2013 -0500

    Add styling hints to <blockquote>-quoted sections

diff --git a/share/static/css/base/history-folding.css b/share/static/css/base/history-folding.css
index b14a7aa..b0935f9 100644
--- a/share/static/css/base/history-folding.css
+++ b/share/static/css/base/history-folding.css
@@ -23,22 +23,43 @@
     color: #000;
 }
 
+.message-stanza > blockquote {
+    margin: 0 0 0 1ex;
+    border-left: 2px #ccc solid;
+    padding-left: 1ex;
+}
+
 .message-stanza .message-stanza{
     color: #500050;
 }
+.message-stanza .message-stanza > blockquote {
+    border-color: #500050;
+}
 
 .message-stanza .message-stanza .message-stanza{
     color: #1a1aa6;
 }
+.message-stanza .message-stanza .message-stanza > blockquote {
+    border-color: #1a1aa6;
+}
 
 .message-stanza .message-stanza .message-stanza .message-stanza {
     color: #006633;
 }
+.message-stanza .message-stanza .message-stanza .message-stanza > blockquote {
+    border-color: #006633;
+}
 
 .message-stanza .message-stanza .message-stanza .message-stanza .message-stanza {
     color: #003366;
 }
+.message-stanza .message-stanza .message-stanza .message-stanza .message-stanza > blockquote {
+    border-color: #003366;
+}
 
 .message-stanza .message-stanza .message-stanza .message-stanza .message-stanza .message-stanza {
     color: #993366;
 }
+.message-stanza .message-stanza .message-stanza .message-stanza .message-stanza .message-stanza > blockquote {
+    border-color: #993366;
+}

commit 6eef6f9fe661434e7ea6810ead8ddd9205f8fec4
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Tue Nov 19 10:20:30 2013 -0500

    More liberal signature detection in HTML mail
    
    Some examples of signature insertion in various clients:
    
    GMail:
      [...]</div>-- <br><div dir="ltr">This is my <b>bold</b> signature!</div>
    
    Thunderbird:
      [...]
      <div class="moz-signature">-- <br>
        This is my <b>bold</b> signature!</div>
    
    Apple mail does not insert sigdashes by default.  When added by hand,
    they are implemented via:
      [...]</div><br><div>
      <div style="[snip]"><div>-- </div><div>This is my<span class="Apple-converted-space"> </span><b>bold</b> signature!</div></div>
      </div>
    ...which is difficult to catch without false-positives.
    
    Unfortunately, Evolution uses:
      [...]<BR>
      <TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%">
      <TR>
      <TD>
      -- <BR>
      This is my <B>bold</B> signature.
      </TD>
      </TR>
      </TABLE>
    ...which is much more difficult to extract, as the whole table would
    need to be stripped.

diff --git a/lib/RT/Transaction.pm b/lib/RT/Transaction.pm
index 151c7a8..2e79e1a 100644
--- a/lib/RT/Transaction.pm
+++ b/lib/RT/Transaction.pm
@@ -343,7 +343,7 @@ sub Content {
         $content = $content_obj->Content ||'';
 
         if ( lc $content_obj->ContentType eq 'text/html' ) {
-            $content =~ s/<p>--\s+<br \/>.*?$//s if $args{'Quote'};
+            $content =~ s/(?:(<\/div>)|<p>|<br\s*\/?>|<div(\s+class="[^"]+")?>)\s*--\s+<br\s*\/?>.*?$/$1/s if $args{'Quote'};
 
             if ($args{Type} ne 'text/html') {
                 $content = RT::Interface::Email::ConvertHTMLToText($content);

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


More information about the rt-commit mailing list