summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Comment.pm
diff options
context:
space:
mode:
authorFrédéric Buclin <LpSolit@gmail.com>2014-02-25 21:42:13 +0100
committerFrédéric Buclin <LpSolit@gmail.com>2014-02-25 21:42:13 +0100
commit0446b5c7b035bcfe9d54d863e8de3864d712c542 (patch)
tree15093889bbc585f304771a94386273264b6fd4a6 /Bugzilla/Comment.pm
parentdee2aa7187553971fb549be116d51c7ff69ee607 (diff)
downloadbugzilla-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/Comment.pm')
-rw-r--r--Bugzilla/Comment.pm9
1 files changed, 9 insertions, 0 deletions
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;
}