RT 4.0.5 bug in Excel export

Hi,

Some HTML stuff is not handled properly, see attachment. It worked
well in RT 3.8.7

I don’t know if it has been fixed in some branch but I experienced
the problem with the last Results.tsv available on github.

BR,
L.B.

Hi,

Some HTML stuff is not handled properly, see attachment. It worked
well in RT 3.8.7

I don’t know if it has been fixed in some branch but I experienced
the problem with the last Results.tsv available on github.

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.

Tim

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.

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.

L.B.

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 RT-Extension-PriorityAsString-1.04 - show priorities in RT as strings instead of numbers - metacpan.org 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.

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 RT-Extension-PriorityAsString-1.04 - show priorities in RT as strings instead of numbers - metacpan.org 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.

Thanks Tim for the investigation.

Hello Ruslan,

Do you plan to upgrade your extension or should I try this hack?

Thanks!
L.B.

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.

Thanks Tim for the investigation.

Hello Ruslan,

Do you plan to upgrade your extension or should I try this hack?

Please don’t CC developers directly, lots of us work on the
extensions. It would be great if Tim filed his patch in the appropriate
rt.cpan.org queue.

-kevin

Please don’t CC developers directly, lots of us work on the
extensions. It would be great if Tim filed his patch in the appropriate
rt.cpan.org queue.

I wasn’t brave enough to do that. It’s not an extension I use - I wrote that patched version direct in my email with code pasted from the CPAN code browser, so it really hasn’t be tested at all. The ColumnMap examples in the Wiki have the same “bug”. Given that all ColumnMap callbacks that worked in RT 3.8 will be affected by this, it could be considered a regression in 4.0 I suppose; the fundamental cause is that the callback happens in share/html/Elements/ColumnMap, which is called by share/html/Search/Results.tsv. Unfortunately, that callback happens after Results.tsv has cbballed the ScrubHTML code.

There might be more satisfactory and general solutions that could be implemented in the Results.tsv mason page. Rather simplistically, it could just run ScrubHTML across everything that comes out of the ColumnMap.

Tim

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.

Please don’t CC developers directly, lots of us work on the
extensions. It would be great if Tim filed his patch in the appropriate
rt.cpan.org queue.

I wasn’t brave enough to do that. It’s not an extension I use - I
wrote that patched version direct in my email with code pasted from
the CPAN code browser, so it really hasn’t be tested at all. The
ColumnMap examples in the Wiki have the same “bug”. Given that all
ColumnMap callbacks that worked in RT 3.8 will be affected by this, it
could be considered a regression in 4.0 I suppose; the fundamental
cause is that the callback happens in share/html/Elements/ColumnMap,
which is called by share/html/Search/Results.tsv. Unfortunately, that
callback happens after Results.tsv has cbballed the ScrubHTML code.

There might be more satisfactory and general solutions that could be
implemented in the Results.tsv mason page. Rather simplistically, it
could just run ScrubHTML across everything that comes out of the
ColumnMap.

Yep, but it wants a bug somewhere (in RT for the possible regression)
or in the module pointing out the problem. Possibly both, with
pointers between them.

I appreciate you digging into it and checking it out.

-kevin

There might be more satisfactory and general solutions that could be implemented in the Results.tsv mason page. Rather simplistically, it could just run ScrubHTML across everything that comes out of the ColumnMap.

Long time ago I send an patch for this but sadly it wasn’t accepted
(Patch 2/2):
http://article.gmane.org/gmane.comp.bug-tracking.request-tracker.devel/6244

-Chris

Am 11.04.2012 17:35, schrieb Tim Cutts:

There might be more satisfactory and general solutions that could be implemented in the Results.tsv mason page. Rather simplistically, it could just run ScrubHTML across everything that comes out of the ColumnMap.

Long time ago I send an patch for this but sadly it wasn’t accepted
(Patch 2/2):
http://article.gmane.org/gmane.comp.bug-tracking.request-tracker.devel/6244

I don’t think you replied to my reply:
http://article.gmane.org/gmane.comp.bug-tracking.request-tracker.devel/6256
or filed a bug with an updated patch with a commit message that
explained the problem.

-kevin

I don’t think you replied to my reply:
http://article.gmane.org/gmane.comp.bug-tracking.request-tracker.devel/6256
or filed a bug with an updated patch with a commit message that
explained the problem.

The patch already contains an commit message that explain the problem
and I don’t know what I should describe more.

-Chris

Am 11.04.2012 23:45, schrieb Kevin Falcone:

I don’t think you replied to my reply:
http://article.gmane.org/gmane.comp.bug-tracking.request-tracker.devel/6256
or filed a bug with an updated patch with a commit message that
explained the problem.

The patch already contains an commit message that explain the
problem and I don’t know what I should describe more.

If you believe your commit is complete, please submit it somewhere to
be applied. The bugtracker or a github pull request are much better
than the archives of rt-devel.

-kevin

FYI, the patch works as expected.

L.B.