diff options
author | Frédéric Buclin <LpSolit@gmail.com> | 2014-02-25 21:42:13 +0100 |
---|---|---|
committer | Frédéric Buclin <LpSolit@gmail.com> | 2014-02-25 21:42:13 +0100 |
commit | 0446b5c7b035bcfe9d54d863e8de3864d712c542 (patch) | |
tree | 15093889bbc585f304771a94386273264b6fd4a6 /Bugzilla/Search.pm | |
parent | dee2aa7187553971fb549be116d51c7ff69ee607 (diff) | |
download | bugzilla-0446b5c7b035bcfe9d54d863e8de3864d712c542.tar.gz bugzilla-0446b5c7b035bcfe9d54d863e8de3864d712c542.tar.xz |
Bug 405011: Text is cut off when containing Unicode supplementary characters (outside BMP) with MySQL as backend
r=gerv a=justdave
Diffstat (limited to 'Bugzilla/Search.pm')
-rw-r--r-- | Bugzilla/Search.pm | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm index b9946889d..399a5b202 100644 --- a/Bugzilla/Search.pm +++ b/Bugzilla/Search.pm @@ -1787,17 +1787,23 @@ sub _handle_chart { my ($field, $operator, $value) = $condition->fov; return if (!defined $field or !defined $operator or !defined $value); $field = FIELD_MAP->{$field} || $field; - - my $string_value; + + my ($string_value, $orig_value); 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') { + @$value = map { _convert_unicode_characters($_) } @$value; + } $string_value = join(',', @$value); } else { return if $value eq ''; + $orig_value = $value; + $value = _convert_unicode_characters($value) if $field eq 'longdesc'; $string_value = $value; } @@ -1844,7 +1850,7 @@ sub _handle_chart { # do_search_function modified them. $self->search_description({ field => $field, type => $operator, - value => $string_value, term => $search_args{term}, + value => $orig_value, term => $search_args{term}, }); foreach my $join (@{ $search_args{joins} }) { @@ -1855,6 +1861,18 @@ sub _handle_chart { $condition->translated(\%search_args); } +# XXX - This is a hack for MySQL which doesn't understand Unicode characters +# above U+FFFF, see Bugzilla::Comment::_check_thetext(). This hack can go away +# once we require MySQL 5.5.3 and use utf8mb4. +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; + } + return $string; +} + ################################## # do_search_function And Helpers # ################################## |