From 0446b5c7b035bcfe9d54d863e8de3864d712c542 Mon Sep 17 00:00:00 2001 From: Frédéric Buclin Date: Tue, 25 Feb 2014 21:42:13 +0100 Subject: Bug 405011: Text is cut off when containing Unicode supplementary characters (outside BMP) with MySQL as backend r=gerv a=justdave --- Bugzilla/Comment.pm | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'Bugzilla/Comment.pm') diff --git a/Bugzilla/Comment.pm b/Bugzilla/Comment.pm index d1e1e2530..0dada24cf 100644 --- a/Bugzilla/Comment.pm +++ b/Bugzilla/Comment.pm @@ -424,6 +424,15 @@ sub _check_thetext { $thetext =~ s/\s*$//s; $thetext =~ s/\r\n?/\n/g; # Get rid of \r. + # Characters above U+FFFF cannot be stored by MySQL older than 5.5.3 as they + # require the new utf8mb4 character set. Other DB servers are handling them + # 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')) { + $thetext =~ s/([\x{10000}-\x{10FFFF}])/"\x{FDD0}[" . uc(sprintf('U+%04x', ord($1))) . "]\x{FDD1}"/eg; + } + ThrowUserError('comment_too_long') if length($thetext) > MAX_COMMENT_LENGTH; return $thetext; } -- cgit v1.2.3-24-g4f1b