[Rt-commit] rt branch, 5.0/subject-tag-unicode-fix, created. rt-5.0.1-460-gc399b9d4eb
Craig Kaiser
craig at bestpractical.com
Wed Jun 16 08:49:00 EDT 2021
The branch, 5.0/subject-tag-unicode-fix has been created
at c399b9d4ebfd866ea2b969e29a0db178634c4875 (commit)
- Log -----------------------------------------------------------------
commit e8452ef0da2f675ffacb78745e180347b3d82c46
Author: craig kaiser <craig at bestpractical.com>
Date: Wed Jun 16 08:45:37 2021 -0400
Add test for subject tag with unicode characters
diff --git a/t/mail/extractsubjecttag.t b/t/mail/extractsubjecttag.t
index 1aadaa7b7d..31d9ab46e9 100644
--- a/t/mail/extractsubjecttag.t
+++ b/t/mail/extractsubjecttag.t
@@ -1,7 +1,8 @@
use strict;
use warnings;
+use utf8;
-use RT::Test tests => 18;
+use RT::Test tests => undef;
my $queue = RT::Test->load_or_create_queue(
Name => 'Regression',
@@ -103,3 +104,25 @@ EOF
unlike($freshticket->Subject,qr/\[\Q$subject_tag\E #$ticketid\]/,'Stripped Queue Subject Tag correctly');
}
+
+$queue = RT::Test->load_or_create_queue(
+ Name => 'Unicode Character Subject Tag Queue',
+ CorrespondAddress => 'rt-recipient at example.com',
+ CommentAddress => 'rt-recipient at example.com',
+);
+$subject_tag = 'Demande générale';
+ok $queue && $queue->id, 'loaded or created queue';
+
+diag "Test System Subject Tag Matches Queue Object Subject Tag";
+{
+ is(RT->System->SubjectTag($queue), undef, 'No Subject Tag yet');
+ my ($status, $msg) = $queue->SetSubjectTag( $subject_tag );
+ ok $status, "set subject tag for the queue" or diag "error: $msg";
+
+ my @subject_tags = RT->System->SubjectTag();
+
+ is($subject_tags[1], $subject_tag, "Set Subject Tag to $subject_tag");
+}
+
+done_testing();
+
commit c399b9d4ebfd866ea2b969e29a0db178634c4875
Author: craig kaiser <craig at bestpractical.com>
Date: Wed Jun 16 08:45:46 2021 -0400
Ensure values returned from DistinctFieldValues are utf8
diff --git a/lib/RT/SearchBuilder.pm b/lib/RT/SearchBuilder.pm
index d070b2ad1f..0471f9d500 100644
--- a/lib/RT/SearchBuilder.pm
+++ b/lib/RT/SearchBuilder.pm
@@ -1070,6 +1070,34 @@ sub NotSetDateToNullFunction {
return $res;
}
+sub DistinctFieldValues {
+ my $self = shift;
+ my $field = shift;
+ my %args = ( decode_utf8 => 1, @_ );
+
+ unless ($field) {
+ $RT::Logger->error("DistinctFieldValues called with undef field");
+ }
+
+ my @values = $self->SUPER::DistinctFieldValues($field);
+
+ my @unicodeValues = ();
+ foreach my $value ( @values ) {
+ if ( $args{'decode_utf8'} ) {
+ if ( !utf8::is_utf8( $value ) ) { # mysql/sqlite
+ utf8::decode( $value );
+ }
+ }
+ else {
+ if ( utf8::is_utf8( $value ) ) {
+ utf8::encode( $value );
+ }
+ }
+ push @unicodeValues, $value;
+ }
+ return @unicodeValues;
+}
+
RT::Base->_ImportOverlays();
1;
-----------------------------------------------------------------------
More information about the rt-commit
mailing list