From e1056ea952c65e24a0f5240ea6e13ac990299440 Mon Sep 17 00:00:00 2001 From: Frédéric Buclin Date: Wed, 26 Feb 2014 11:14:08 +0100 Subject: Remove "Unicode non-character 0xfdd0 is illegal for interchange" warnings thrown by Perl 5.10.1 and 5.12, see bug 405011 r=gerv --- Bugzilla/Bug.pm | 9 ++++++--- Bugzilla/Comment.pm | 5 ++++- Bugzilla/Search.pm | 16 ++++++++++------ 3 files changed, 20 insertions(+), 10 deletions(-) (limited to 'Bugzilla') diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index 73b50018a..dd22426bb 100644 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -3412,15 +3412,18 @@ sub comments { if (!defined $self->{'comments'}) { $self->{'comments'} = Bugzilla::Comment->match({ bug_id => $self->id }); my $count = 0; - my $is_mysql = Bugzilla->dbh->isa('Bugzilla::DB::Mysql') ? 1 : 0; + state $is_mysql = Bugzilla->dbh->isa('Bugzilla::DB::Mysql') ? 1 : 0; foreach my $comment (@{ $self->{'comments'} }) { $comment->{count} = $count++; $comment->{bug} = $self; # XXX - hack for MySQL. Convert [U+....] back into its Unicode # equivalent for characters above U+FFFF as MySQL older than 5.5.3 # cannot store them, see Bugzilla::Comment::_check_thetext(). - $comment->{thetext} =~ s/\x{FDD0}\[U\+((?:[1-9A-F]|10)[0-9A-F]{4})\]\x{FDD1}/chr(hex $1)/eg - if $is_mysql; + if ($is_mysql) { + # Perl 5.13.8 and older complain about non-characters. + no warnings 'utf8'; + $comment->{thetext} =~ s/\x{FDD0}\[U\+((?:[1-9A-F]|10)[0-9A-F]{4})\]\x{FDD1}/chr(hex $1)/eg + } } # Some bugs may have no comments when upgrading old installations. Bugzilla::Comment->preload($self->{'comments'}) if $count; diff --git a/Bugzilla/Comment.pm b/Bugzilla/Comment.pm index 0dada24cf..238770d57 100644 --- a/Bugzilla/Comment.pm +++ b/Bugzilla/Comment.pm @@ -429,7 +429,10 @@ sub _check_thetext { # without any problem. So we need to replace these characters if we use MySQL, # else the comment is truncated. # XXX - Once we use utf8mb4 for comments, this hack for MySQL can go away. - if (Bugzilla->dbh->isa('Bugzilla::DB::Mysql')) { + state $is_mysql = Bugzilla->dbh->isa('Bugzilla::DB::Mysql') ? 1 : 0; + if ($is_mysql) { + # Perl 5.13.8 and older complain about non-characters. + no warnings 'utf8'; $thetext =~ s/([\x{10000}-\x{10FFFF}])/"\x{FDD0}[" . uc(sprintf('U+%04x', ord($1))) . "]\x{FDD1}"/eg; } diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm index 399a5b202..23c632996 100644 --- a/Bugzilla/Search.pm +++ b/Bugzilla/Search.pm @@ -1789,13 +1789,15 @@ sub _handle_chart { $field = FIELD_MAP->{$field} || $field; my ($string_value, $orig_value); + state $is_mysql = $dbh->isa('Bugzilla::DB::Mysql') ? 1 : 0; + if (ref $value eq 'ARRAY') { # Trim input and ignore blank values. @$value = map { trim($_) } @$value; @$value = grep { defined $_ and $_ ne '' } @$value; return if !@$value; $orig_value = join(',', @$value); - if ($field eq 'longdesc') { + if ($field eq 'longdesc' && $is_mysql) { @$value = map { _convert_unicode_characters($_) } @$value; } $string_value = join(',', @$value); @@ -1803,10 +1805,12 @@ sub _handle_chart { else { return if $value eq ''; $orig_value = $value; - $value = _convert_unicode_characters($value) if $field eq 'longdesc'; + if ($field eq 'longdesc' && $is_mysql) { + $value = _convert_unicode_characters($value); + } $string_value = $value; } - + $self->_chart_fields->{$field} or ThrowCodeError("invalid_field_name", { field => $field }); trick_taint($field); @@ -1867,9 +1871,9 @@ sub _handle_chart { sub _convert_unicode_characters { my $string = shift; - if (Bugzilla->dbh->isa('Bugzilla::DB::Mysql')) { - $string =~ s/([\x{10000}-\x{10FFFF}])/"\x{FDD0}[" . uc(sprintf('U+%04x', ord($1))) . "]\x{FDD1}"/eg; - } + # Perl 5.13.8 and older complain about non-characters. + no warnings 'utf8'; + $string =~ s/([\x{10000}-\x{10FFFF}])/"\x{FDD0}[" . uc(sprintf('U+%04x', ord($1))) . "]\x{FDD1}"/eg; return $string; } -- cgit v1.2.3-24-g4f1b