[Rt-commit] rt branch, 4.2/warn-on-case-sensitive-searches, updated. rt-4.1.8-155-g205a7be

Ruslan Zakirov ruz at bestpractical.com
Mon Apr 22 08:44:14 EDT 2013


The branch, 4.2/warn-on-case-sensitive-searches has been updated
       via  205a7bee6adee0b6b1e0a403f4f76dd403494711 (commit)
       via  34874251421adb10fd054803aab7776aa5f63cf2 (commit)
      from  c29fadc3d9af2b62b5f41e914436f452d9619dcf (commit)

Summary of changes:
 lib/RT/Articles.pm                 |  3 ++-
 lib/RT/Groups.pm                   | 12 ++++++------
 lib/RT/SearchBuilder.pm            |  6 ++++--
 lib/RT/SearchBuilder/Role/Roles.pm |  1 +
 lib/RT/Test.pm                     |  5 ++++-
 lib/RT/Tickets.pm                  |  5 +++--
 lib/RT/Transaction.pm              |  2 +-
 t/customfields/ip.t                |  2 +-
 t/customfields/iprange.t           |  2 +-
 t/customfields/iprangev6.t         |  2 +-
 t/customfields/ipv6.t              |  2 +-
 11 files changed, 25 insertions(+), 17 deletions(-)

- Log -----------------------------------------------------------------
commit 34874251421adb10fd054803aab7776aa5f63cf2
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sun Apr 21 16:33:02 2013 +0400

    fix catches case sensitive searches by CF name

diff --git a/lib/RT/Articles.pm b/lib/RT/Articles.pm
index d69eabf..defed2a 100644
--- a/lib/RT/Articles.pm
+++ b/lib/RT/Articles.pm
@@ -314,7 +314,8 @@ sub LimitCustomField {
             $self->Limit( ALIAS => $fields,
                           FIELD => 'Name',
                           VALUE => $args{'FIELD'},
-                          ENTRYAGGREGATOR  => 'OR');
+                          ENTRYAGGREGATOR  => 'OR',
+                          CASESENSITIVE => 0);
             $self->Limit(
                 ALIAS => $fields,
                 FIELD => 'LookupType',
diff --git a/lib/RT/SearchBuilder.pm b/lib/RT/SearchBuilder.pm
index 383cca3..6c4b81f 100644
--- a/lib/RT/SearchBuilder.pm
+++ b/lib/RT/SearchBuilder.pm
@@ -315,7 +315,9 @@ sub Limit {
     }
 
     unless ( exists $ARGS{CASESENSITIVE} ) {
-        if ( $table && $check_case_sensitivity{ lc $table }{ lc $ARGS{'FIELD'} } ) {
+        if ( $ARGS{'OPERATOR'} !~ /IS/i
+            && $table && $check_case_sensitivity{ lc $table }{ lc $ARGS{'FIELD'} }
+        ) {
             RT->Logger->warning(
                 "Case sensitive search by $table.$ARGS{'FIELD'}"
                 ." at ". (caller)[1] . " line ". (caller)[2]
diff --git a/lib/RT/Transaction.pm b/lib/RT/Transaction.pm
index 8c61777..4e69b30 100644
--- a/lib/RT/Transaction.pm
+++ b/lib/RT/Transaction.pm
@@ -1336,7 +1336,7 @@ sub LoadCustomFieldByIdentifier {
 
     my $CFs = RT::CustomFields->new( $self->CurrentUser );
     $CFs->SetContextObject( $self->Object );
-    $CFs->Limit( FIELD => 'Name', VALUE => $field );
+    $CFs->Limit( FIELD => 'Name', VALUE => $field, CASESENSITIVE => 0 );
     $CFs->LimitToLookupType($self->CustomFieldLookupType);
     $CFs->LimitToGlobalOrObjectId($self->Object->QueueObj->id);
     return $CFs->First || RT::CustomField->new( $self->CurrentUser );
diff --git a/t/customfields/ip.t b/t/customfields/ip.t
index 60e68a4..2537b1e 100644
--- a/t/customfields/ip.t
+++ b/t/customfields/ip.t
@@ -26,7 +26,7 @@ my $cf;
 diag "load and check basic properties of the IP CF" if $ENV{'TEST_VERBOSE'};
 {
     my $cfs = RT::CustomFields->new($RT::SystemUser);
-    $cfs->Limit( FIELD => 'Name', VALUE => 'IP' );
+    $cfs->Limit( FIELD => 'Name', VALUE => 'IP', CASESENSITIVE => 0 );
     is( $cfs->Count, 1, "found one CF with name 'IP'" );
 
     $cf = $cfs->First;
diff --git a/t/customfields/iprange.t b/t/customfields/iprange.t
index 943e412..c99d1f1 100644
--- a/t/customfields/iprange.t
+++ b/t/customfields/iprange.t
@@ -21,7 +21,7 @@ my $cf;
 diag "load and check basic properties of the IP CF" if $ENV{'TEST_VERBOSE'};
 {
     my $cfs = RT::CustomFields->new( $RT::SystemUser );
-    $cfs->Limit( FIELD => 'Name', VALUE => 'IP' );
+    $cfs->Limit( FIELD => 'Name', VALUE => 'IP', CASESENSITIVE => 0 );
     is( $cfs->Count, 1, "found one CF with name 'IP'" );
 
     $cf = $cfs->First;
diff --git a/t/customfields/iprangev6.t b/t/customfields/iprangev6.t
index 3b8a4d6..3d73a23 100644
--- a/t/customfields/iprangev6.t
+++ b/t/customfields/iprangev6.t
@@ -21,7 +21,7 @@ my $cf;
 diag "load and check basic properties of the IP CF" if $ENV{'TEST_VERBOSE'};
 {
     my $cfs = RT::CustomFields->new( $RT::SystemUser );
-    $cfs->Limit( FIELD => 'Name', VALUE => 'IP' );
+    $cfs->Limit( FIELD => 'Name', VALUE => 'IP', CASESENSITIVE => 0 );
     is( $cfs->Count, 1, "found one CF with name 'IP'" );
 
     $cf = $cfs->First;
diff --git a/t/customfields/ipv6.t b/t/customfields/ipv6.t
index ad34f42..9c82d0d 100644
--- a/t/customfields/ipv6.t
+++ b/t/customfields/ipv6.t
@@ -26,7 +26,7 @@ my $cf;
 diag "load and check basic properties of the IP CF" if $ENV{'TEST_VERBOSE'};
 {
     my $cfs = RT::CustomFields->new($RT::SystemUser);
-    $cfs->Limit( FIELD => 'Name', VALUE => 'IP' );
+    $cfs->Limit( FIELD => 'Name', VALUE => 'IP', CASESENSITIVE => 0 );
     is( $cfs->Count, 1, "found one CF with name 'IP'" );
 
     $cf = $cfs->First;

commit 205a7bee6adee0b6b1e0a403f4f76dd403494711
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Mon Apr 22 16:43:34 2013 +0400

    case insensitive search by Groups.Domain

diff --git a/lib/RT/Groups.pm b/lib/RT/Groups.pm
index 8d30dde..1cfad14 100644
--- a/lib/RT/Groups.pm
+++ b/lib/RT/Groups.pm
@@ -141,7 +141,7 @@ Return only SystemInternal Groups, such as "privileged" "unprivileged" and "ever
 
 sub LimitToSystemInternalGroups {
     my $self = shift;
-    $self->Limit(FIELD => 'Domain', OPERATOR => '=', VALUE => 'SystemInternal');
+    $self->Limit(FIELD => 'Domain', OPERATOR => '=', VALUE => 'SystemInternal', CASESENSITIVE => 0 );
     # All system internal groups have the same instance. No reason to limit down further
     #$self->Limit(FIELD => 'Instance', OPERATOR => '=', VALUE => '0');
 }
@@ -158,7 +158,7 @@ Return only UserDefined Groups
 
 sub LimitToUserDefinedGroups {
     my $self = shift;
-    $self->Limit(FIELD => 'Domain', OPERATOR => '=', VALUE => 'UserDefined');
+    $self->Limit(FIELD => 'Domain', OPERATOR => '=', VALUE => 'UserDefined', CASESENSITIVE => 0 );
     # All user-defined groups have the same instance. No reason to limit down further
     #$self->Limit(FIELD => 'Instance', OPERATOR => '=', VALUE => '');
 }
@@ -178,7 +178,7 @@ L</LimitToRolesForSystem>.
 sub LimitToRolesForObject {
     my $self   = shift;
     my $object = shift;
-    $self->Limit(FIELD => 'Domain',   OPERATOR => '=', VALUE => ref($object) . "-Role");
+    $self->Limit(FIELD => 'Domain',   OPERATOR => '=', VALUE => ref($object) . "-Role", CASESENSITIVE => 0 );
     $self->Limit(FIELD => 'Instance', OPERATOR => '=', VALUE => $object->id)
         if $object->id and not ref($object) eq "RT::System";
 }
@@ -198,7 +198,7 @@ sub LimitToRolesForQueue {
         Instead => "LimitToRolesForObject",
         Remove => "4.4",
     );
-    $self->Limit(FIELD => 'Domain', OPERATOR => '=', VALUE => 'RT::Queue-Role');
+    $self->Limit(FIELD => 'Domain', OPERATOR => '=', VALUE => 'RT::Queue-Role', CASESENSITIVE => 0 );
     $self->Limit(FIELD => 'Instance', OPERATOR => '=', VALUE => $queue);
 }
 
@@ -219,7 +219,7 @@ sub LimitToRolesForTicket {
         Instead => "LimitToRolesForObject",
         Remove => "4.4",
     );
-    $self->Limit(FIELD => 'Domain', OPERATOR => '=', VALUE => 'RT::Ticket-Role');
+    $self->Limit(FIELD => 'Domain', OPERATOR => '=', VALUE => 'RT::Ticket-Role', CASESENSITIVE => 0 );
     $self->Limit(FIELD => 'Instance', OPERATOR => '=', VALUE => $Ticket);
 }
 
@@ -239,7 +239,7 @@ sub LimitToRolesForSystem {
         Instead => "LimitToRolesForObject",
         Remove => "4.4",
     );
-    $self->Limit(FIELD => 'Domain', OPERATOR => '=', VALUE => 'RT::System-Role');
+    $self->Limit(FIELD => 'Domain', OPERATOR => '=', VALUE => 'RT::System-Role', CASESENSITIVE => 0 );
 }
 
 
diff --git a/lib/RT/SearchBuilder.pm b/lib/RT/SearchBuilder.pm
index 6c4b81f..697f8c3 100644
--- a/lib/RT/SearchBuilder.pm
+++ b/lib/RT/SearchBuilder.pm
@@ -255,7 +255,7 @@ injection attacks when we pass through user specified values.
 =cut
 
 my %check_case_sensitivity = (
-    groups => { 'name' => 1 },
+    groups => { 'name' => 1, domain => 1 },
     queues => { 'name' => 1 },
     users => { 'name' => 1, emailaddress => 1 },
     customfields => { 'name' => 1 },
diff --git a/lib/RT/SearchBuilder/Role/Roles.pm b/lib/RT/SearchBuilder/Role/Roles.pm
index 7b89244..b61d148 100644
--- a/lib/RT/SearchBuilder/Role/Roles.pm
+++ b/lib/RT/SearchBuilder/Role/Roles.pm
@@ -131,6 +131,7 @@ sub _RoleGroupsJoin {
         ALIAS           => $groups,
         FIELD           => 'Domain',
         VALUE           => $args{'Class'} .'-Role',
+        CASESENSITIVE   => 0,
     );
     $self->Limit(
         LEFTJOIN        => $groups,
diff --git a/lib/RT/Test.pm b/lib/RT/Test.pm
index 4496d05..161ddd6 100644
--- a/lib/RT/Test.pm
+++ b/lib/RT/Test.pm
@@ -717,7 +717,10 @@ sub load_or_create_user {
         my $groups_alias = $gms->Join(
             FIELD1 => 'GroupId', TABLE2 => 'Groups', FIELD2 => 'id',
         );
-        $gms->Limit( ALIAS => $groups_alias, FIELD => 'Domain', VALUE => 'UserDefined' );
+        $gms->Limit(
+            ALIAS => $groups_alias, FIELD => 'Domain', VALUE => 'UserDefined',
+            CASESENSITIVE => 0,
+        );
         $gms->Limit( FIELD => 'MemberId', VALUE => $obj->id );
         while ( my $group_member_record = $gms->Next ) {
             $group_member_record->Delete;
diff --git a/lib/RT/Tickets.pm b/lib/RT/Tickets.pm
index 2767167..4a707c2 100644
--- a/lib/RT/Tickets.pm
+++ b/lib/RT/Tickets.pm
@@ -972,7 +972,8 @@ sub _WatcherMembershipLimit {
         ALIAS           => $groups,
         FIELD           => 'Domain',
         VALUE           => 'RT::Ticket-Role',
-        ENTRYAGGREGATOR => 'AND'
+        ENTRYAGGREGATOR => 'AND',
+        CASESENSITIVE   => 0,
     );
 
     $self->Join(
@@ -2936,7 +2937,7 @@ sub CurrentUserCanSee {
     if ( my @tmp = grep $_ ne 'Owner' && !ref $roles{ $_ }, keys %roles ) {
 
         my $groups = RT::Groups->new( RT->SystemUser );
-        $groups->Limit( FIELD => 'Domain', VALUE => 'RT::Queue-Role' );
+        $groups->Limit( FIELD => 'Domain', VALUE => 'RT::Queue-Role', CASESENSITIVE => 0 );
         foreach ( @tmp ) {
             $groups->Limit( FIELD => 'Name', VALUE => $_, CASESENSITIVE => 0 );
         }

-----------------------------------------------------------------------


More information about the Rt-commit mailing list