[rt-users] RT 4.0.5 bug in Excel export

Tim Cutts tjrc at sanger.ac.uk
Wed Apr 11 08:35:26 EDT 2012


On 11 Apr 2012, at 10:25, L B wrote:

>> 
>> I saw a similar thing when using Status with a CustomStatus callback which colours my statuses (as in the example in the Wiki).
>> 
>> The problem in that case was that the callback was being called *after* the Excel export does its ScrubHTML bit, so HTML gets through.  I had to alter my callback so that it checked if the request for a Results page.
>> 
>> This looks like a similar issue.  Are you using any callbacks or extensions which change how the priorities are displayed in your web pages?  If you are, that's probably the cause.
> 
> Yes, I use http://search.cpan.org/dist/RT-Extension-PriorityAsString/ extension.

Aha!  The issue here is not a bug in RT 4.x at all, but merely a plugin which hasn't been updated for RT 4.

What you need to do is modify the callback in that extension (html/Callbacks/PriorityAsString/Elements/RT__Ticket/ColumnMap/Once) so that it doesn't do all that snazzy html when the request is for Results.tsv.  Something like this might work [WARNING:  Untested code!]:

<%ARGS>
$COLUMN_MAP => {}
</%ARGS>
<%INIT>
my $printer = sub {
    my ($class, $string) = @_;
    return '' unless defined $string && length $string;

    my $request_path = $HTML::Mason::Commands::r->path_info;

    if ($request_path =~ /Results\.tsv/) {
        return \"$string";
    }

    my $escaped = $m->interp->apply_escapes($string, 'h');
    my $loc_escaped = $m->interp->apply_escapes(loc($string), 'h');
    return \( qq{<span class="ticket-info-$class-}. lc($escaped) .qq{">$loc_escaped</span>} );
    
};
foreach my $field (qw(Priority InitialPriority FinalPriority)) {
    $COLUMN_MAP->{ $field .'Number' } ||= $COLUMN_MAP->{ $field };

    my $class = lc($field);
    $class =~ s/(?=<.)(?=priority)/-/;

    my $method = $field .'AsString';

    $COLUMN_MAP->{ $field }{'value'} = sub {
        return $printer->( $class, $_[0]->$method() );
    };
}
return;
</%INIT>

-- 
 The Wellcome Trust Sanger Institute is operated by Genome Research 
 Limited, a charity registered in England with number 1021457 and a 
 company registered in England with number 2742969, whose registered 
 office is 215 Euston Road, London, NW1 2BE. 



More information about the rt-users mailing list