[Rt-commit] r6453 - in rt/branches/3.6-RELEASE: html
ruz at bestpractical.com
ruz at bestpractical.com
Sat Nov 18 15:08:32 EST 2006
Author: ruz
Date: Sat Nov 18 15:08:31 2006
New Revision: 6453
Modified:
rt/branches/3.6-RELEASE/html/autohandler
rt/branches/3.6-RELEASE/lib/t/regression/21query-builder.t
Log:
* fix problems in building queries with CF conditions based on
CFs with not-ascii names
** bug fix for #8012 at rt3.fsck.com and may be other bugs related
to not-ascii keys in the %ARGS.
** add a test
Additional info:
Use $m->comp( { base_comp => $m->request_comp }, $m->fetch_next, %ARGS );
instead of $m->call_next to avoid problems with UTF8 keys in arguments.
The call_next method pass through original arguments and if you have
an argument with unicode key then in a next component you'll get two
records in the args hash: one with key without UTF8 flag and another
with the flag, which may result into errors. "{ base_comp => $m->request_comp }"
is copied from mason's source to get the same results as we get from
call_next method, this feature is not documented, so we just leave it
here to avoid possible side effects.
Modified: rt/branches/3.6-RELEASE/html/autohandler
==============================================================================
--- rt/branches/3.6-RELEASE/html/autohandler (original)
+++ rt/branches/3.6-RELEASE/html/autohandler Sat Nov 18 15:08:31 2006
@@ -90,6 +90,17 @@
: $_
} %ARGS;
+# Latter in the code we use
+# $m->comp( { base_comp => $m->request_comp }, $m->fetch_next, %ARGS );
+# instead of $m->call_next to avoid problems with UTF8 keys in arguments.
+# The call_next method pass through original arguments and if you have
+# an argument with unicode key then in a next component you'll get two
+# records in the args hash: one with key without UTF8 flag and another
+# with the flag, which may result into errors. "{ base_comp => $m->request_comp }"
+# is copied from mason's source to get the same results as we get from
+# call_next method, this feature is not documented, so we just leave it
+# here to avoid possible side effects.
+
# This code canonicalizes time inputs in hours into minutes
foreach my $field ( keys %ARGS ) {
next unless $field =~ /^(.*)-TimeUnits$/i && $ARGS{$1};
@@ -115,7 +126,7 @@
# If it's a noauth file, don't ask for auth.
if ( $m->base_comp->path =~ $RT::WebNoAuthRegex ) {
- $m->call_next(%ARGS);
+ $m->comp( { base_comp => $m->request_comp }, $m->fetch_next, %ARGS);
$m->abort;
}
@@ -274,11 +285,11 @@
$m->abort();
}
else {
- $m->call_next(%ARGS);
+ $m->comp( { base_comp => $m->request_comp }, $m->fetch_next, %ARGS);
}
}
else {
- $m->call_next(%ARGS);
+ $m->comp( { base_comp => $m->request_comp }, $m->fetch_next, %ARGS);
}
}
Modified: rt/branches/3.6-RELEASE/lib/t/regression/21query-builder.t
==============================================================================
--- rt/branches/3.6-RELEASE/lib/t/regression/21query-builder.t (original)
+++ rt/branches/3.6-RELEASE/lib/t/regression/21query-builder.t Sat Nov 18 15:08:31 2006
@@ -1,7 +1,7 @@
#!/usr/bin/perl
use strict;
-use Test::More tests => 35;
+use Test::More tests => 39;
use Test::WWW::Mechanize;
use HTTP::Request::Common;
use HTTP::Cookies;
@@ -213,4 +213,32 @@
# }}}
+# create a custom field with nonascii name and try to add a condition
+{
+ my $cf = RT::CustomField->new( $RT::SystemUser );
+ $cf->LoadByName( Name => "\x{442}", Queue => 0 );
+ if ( $cf->id ) {
+ is($cf->Type, 'Freeform', 'loaded and type is correct');
+ } else {
+ my ($return, $msg) = $cf->Create(
+ Name => "\x{442}",
+ Queue => 0,
+ Type => 'Freeform',
+ );
+ ok($return, 'created CF') or diag "error: $msg";
+ }
+
+ my $response = $agent->get($url."Search/Build.html?NewQuery=1");
+ ok( $response->is_success, "Fetched " . $url."Search/Build.html" );
+
+ ok($agent->form_name('BuildQuery'), "found the form once");
+ $agent->field("ValueOf'CF.{\321\202}'", "\321\201");
+ $agent->submit();
+ is( getQueryFromForm,
+ "'CF.{\321\202}' LIKE '\321\201'",
+ "no changes, no duplicate condition with badly encoded text"
+ );
+
+}
+
1;
More information about the Rt-commit
mailing list