[rt-users] HTML Email and RT 3.0.6

jflanders at burrelles.com jflanders at burrelles.com
Thu Oct 23 23:09:11 EDT 2003


Thanks for the prior responses about my problem with RT not showing 
the body of an email in the ticket, it turns out it was indeed because 
the email was HTML and not text. I tried Cubic idea first installed 
HTML::Scrubber and edited the ShowTransaction file adding the lines 
if ($message->ContentType =~ m{^text/html$}i &&
				    $message->ContentLength < 
$MAX_INLINE_BODY ) {
         use HTML::Scrubber;
    my @allow = qw[a br];
    my @rules = (
        script => 0,
        img => {
            src => qr{^(?:http://)}i, # only relative image links 
allowed
            alt => 1,                 # alt attribute allowed
            '*' => 0,                 # deny all other attributes
        },
    );
    my @default = (
        0   =>    # default rule, deny all tags
        {
            '*'           => 1, # default rule, allow all attributes
            'href'        => qr{^(?!(?:java)?script)}i,
            'src'         => qr{^(?!(?:java)?script)}i,
            'cite'        => qr{(?i-xsm:^(?!(?:java)?script))},
            'language'    => 0,
            'name'        => 0, # could be sneaky, but hey ;)
            'onblur'      => 0,
            'onchange'    => 0,
            'onclick'     => 0,
            'ondblclick'  => 0,
            'onerror'     => 0,
            'onfocus'     => 0,
            'onkeydown'   => 0,
            'onkeypress'  => 0,
            'onkeyup'     => 0,
            'onload'      => 0,
            'onmousedown' => 0,
            'onmousemove' => 0,
            'onmouseout'  => 0,
            'onmouseover' => 0,
            'onmouseup'   => 0,
            'onreset'     => 0,
            'onselect'    => 0,
            'onsubmit'    => 0,
            'onunload'    => 0,
            'src'         => 0,
            'type'        => 0,
        }
    );
    my $scrubber = HTML::Scrubber->new(
        allow   => \@allow,
        rules   => \@rules,
        default => \@default,
        comment => 0,
        process => 0,
    );
    my $scrubed = $scrubber->scrub($message->Content);
    $scrubed =~ s/^\s*?(?:<br>)*\s*?\n//sg;
    $scrubed =~ s/<br>/\n/g;
    $scrubed =~ s/<a.*?href\s*=\s*"(.*?)">(.*?)<\/a>/$1 - $2/g;
    $scrubed =~ s/<img.*?src\s*=\s*"(.*?)">/\nImage: $1\n/g;
         require Text::Quoted;
	 $quoted = Text::Quoted::extract($scrubed); 
     }
Now when I send an HTML I get this in the Body of the ticket

<!-- 
/* Style Definitions */ 
p.MsoNormal, li.MsoNormal, div.MsoNormal 
{margin:0in; 
margin-bottom:.0001pt; 
font-size:12.0pt; 
font-family:"Times New Roman";} 
a:link, span.MsoHyperlink 
{color:blue; 
text-decoration:underline;} 
a:visited, span.MsoHyperlinkFollowed 
{color:purple; 
text-decoration:underline;} 
span.EmailStyle17 
{font-family:Arial; 
color:windowtext;} 
@page Section1 
{size:8.5in 11.0in; 
margin:1.0in 1.25in 1.0in 1.25in;} 
div.Section1 
{page:Section1;} 
--> 








Test Ticket in HTML

Also it has a This Transaction Has No Content in the replies to the 
Admin CC and requester where the plain text email had the body.  Any 
ideas.. if not I’m going to try jwlia's idea of the external stripper 
demime.  

Also when I use {$Transaction->Content()} in a template for a scrip 
that is used when the owner is changed it won't include the body just 
'This Transaction Has No Content' my guess is an owner change doesn't 
cause the Transaction->Content to be invoked.  Is there another way to 
get the body of the ticket to print?  I want the new owner of the 
ticket to know what its about without having to log into RT.




More information about the rt-users mailing list