[Rt-devel] [Rt-commit] rt branch, 4.0/dashboard-chart-with-umlauts, created. rt-4.0.1-298-gc6fb9f5
sunnavy
sunnavy at bestpractical.com
Tue Aug 9 01:20:23 EDT 2011
On 11-08-08 21:13, Ruslan Zakirov wrote:
> Regards, Ruslan. From phone.
> 08.08.2011 14:01 пользователь "? sunnavy" <sunnavy at bestpractical.com>
> написал:
> >
> > The branch, 4.0/dashboard-chart-with-umlauts has been created
> > at c6fb9f54c37142df0089145c12ab4feab52d7d27 (commit)
> >
> > - Log -----------------------------------------------------------------
> > commit c0ec1787729093b2064a36c9ef5cce5e84b763d5
> > Author: sunnavy <sunnavy at bestpractical.com>
> > Date: Mon Aug 8 17:31:41 2011 +0800
> >
> > turn off utf8 as uri string is utf8 encoded, see also #18104
> >
> > diff --git a/lib/RT/Dashboard/Mailer.pm b/lib/RT/Dashboard/Mailer.pm
> > index f6b1685..ae10d21 100644
> > --- a/lib/RT/Dashboard/Mailer.pm
> > +++ b/lib/RT/Dashboard/Mailer.pm
> > @@ -476,7 +476,9 @@ sub BuildEmail {
> > }
> >
> > sub GetResource {
> > - my $uri = URI->new(shift);
> > + my $string = shift;
> > + Encode::_utf8_off($string);
> > + my $uri = URI->new($string);
>
> Shouldn't uri be escaped and contain only ASCII? I see this masking real
> issue.
yep, but those ascii with utf8 flag on makes URI interpret uri escaped utf8
encoded data differently, here is the detail:
"äöü" is escaped to "%C3%A4%C3%B6%C3%BC"
use Devel::StringInfo 'string_info';
my $uri = URI->new('?Query=%C3%A4%C3%B6%C3%BC');
print string_info( ($uri->query_form('Query'))[1] );
output:
string: äöü
is_utf8: 0
octet_length: 6
valid_utf8: 1
decoded_is_same: 0
decoded:
octet_length: 6
downgradable: 1
char_length: 3
string: äöü
is_utf8: 1
raw = <<äöü>>
this is right.
but if utf8 flag of "%C3%A4%C3%B6%C3%BC" is on:
use Encode;
use Devel::StringInfo 'string_info';
my $uri = URI->new(decode_utf8 '?Query=%C3%A4%C3%B6%C3%BC');
print string_info( ($uri->query_form('Query'))[1] );
output:
string: äöü
is_utf8: 1
char_length: 6
octet_length: 12
downgradable: 1
raw = <<äöü>>
this is not right, the char_length should be 3 and octet_length should be 6
>
> > my ($content, $filename, $mimetype, $encoding);
> >
> > $RT::Logger->debug("Getting resource $uri");
> >
> > commit c6fb9f54c37142df0089145c12ab4feab52d7d27
> > Author: sunnavy <sunnavy at bestpractical.com>
> > Date: Mon Aug 8 17:31:58 2011 +0800
> >
> > test for dashboard chart with umlauts
> >
> > diff --git a/t/mail/dashboard-chart-with-umlauts.t
> b/t/mail/dashboard-chart-with-umlauts.t
> > new file mode 100644
> > index 0000000..cfde407
> > --- /dev/null
> > +++ b/t/mail/dashboard-chart-with-umlauts.t
> > @@ -0,0 +1,88 @@
> > +use strict;
> > +use warnings;
> > +
> > +use RT::Test tests => 19;
> > +use RT::Dashboard::Mailer;
> > +use Encode;
> > +
> > +my $root = RT::Test->load_or_create_user( Name => 'root' );
> > +
> > +my ( $baseurl, $m ) = RT::Test->started_ok;
> > +ok( $m->login, 'logged in' );
> > +
> > +RT::Test->create_ticket(
> > + Queue => 'General',
> > + Subject => decode_utf8('test äöü'),
> > +);
> > +
> > +my $query = "Subject LIKE 'test äöü'";
> > +
> > +$m->get_ok(q{/Search/Chart.html?Query=Subject LIKE 'test äöü'});
> > +$m->submit_form(
> > + form_name => 'SaveSearch',
> > + fields => {
> > + SavedSearchDescription => 'chart foo',
> > + SavedSearchOwner => 'RT::User-' . $root->id,
> > + },
> > + button => 'SavedSearchSave',
> > +);
> > +
> > +# first, create and populate a dashboard
> > +$m->get_ok('/Dashboards/Modify.html?Create=1');
> > +$m->form_name('ModifyDashboard');
> > +$m->field( 'Name' => 'dashboard foo' );
> > +$m->click_button( value => 'Create' );
> > +
> > +$m->follow_link_ok( { text => 'Content' } );
> > +my $form = $m->form_name('Dashboard-Searches-body');
> > +my @input = $form->find_input('Searches-body-Available');
> > +my ($dashboards_component) =
> > + map { ( $_->possible_values )[1] }
> > + grep { ( $_->value_names )[1] =~ /^Chart/ } @input;
> > +$form->value( 'Searches-body-Available' => $dashboards_component );
> > +$m->click_button( name => 'add' );
> > +$m->content_contains('Dashboard updated');
> > +
> > +$m->follow_link_ok( { text => 'Subscription' } );
> > +$m->form_name('SubscribeDashboard');
> > +$m->field( 'Frequency' => 'daily' );
> > +$m->field( 'Hour' => '06:00' );
> > +$m->click_button( name => 'Save' );
> > +$m->content_contains('Subscribed to dashboard dashboard foo');
> > +
> > +$m->follow_link_ok( { text => 'Show' } );
> > +my ($src) = $m->content =~ qr{src="(/Search/Chart\?.*?)"};
> > +ok( $src, 'have chart image' );
> > +my $c = $m->get($src);
> > +my $image = $c->content;
> > +
> > +RT::Dashboard::Mailer->MailDashboards( All => 1 );
> > +
> > +my @mails = RT::Test->fetch_caught_mails;
> > +is @mails, 1, "got a dashboard mail";
> > +
> > +# can't use parse_mail here is because it deletes all attachments
> > +# before we can call bodyhandle :/
> > +use RT::EmailParser;
> > +my $parser = RT::EmailParser->new;
> > +$parser->ParseMIMEEntityFromScalar( $mails[0] );
> > +my $mail = $parser->ParseMIMEEntityFromScalar( $mails[0] );
> > +like(
> > + $mail->head->get('Subject'),
> > + qr/Daily Dashboard: dashboard foo/,
> > + 'mail subject'
> > +);
> > +
> > +my ($mail_image) = grep { $_->mime_type eq 'image/png' } $mail->parts;
> > +ok( $mail_image, 'mail contains image attachment' );
> > +
> > +my $handle = $mail_image->bodyhandle;
> > +
> > +my $mail_image_data = '';
> > +if ( my $io = $handle->open('r') ) {
> > + while ( defined( $_ = $io->getline ) ) { $mail_image_data .= $_ }
> > + $io->close;
> > +}
> > +
> > +is( $mail_image_data, $image, 'image in mail is the same one in web' );
> > +
> >
> > -----------------------------------------------------------------------
> >
> > _______________________________________________
> > Rt-commit mailing list
> > Rt-commit at lists.bestpractical.com
> > http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-commit
> >
> _______________________________________________
> Come work for us: http://blog.bestpractical.com/2011/06/were-hiring-come-hack-perl-for-best-practical.html
> 2011 Training: http://bestpractical.com/services/training.html
> List info: http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-devel
More information about the rt-devel
mailing list