From 9f0310bf8c0821347699b434f659eb52decabf87 Mon Sep 17 00:00:00 2001 From: "mkanat%bugzilla.org" <> Date: Fri, 23 Nov 2007 12:58:33 +0000 Subject: Bug 363153: Turn on the utf8 bit on all strings in Bugzilla that contain non-ASCII data, if the utf8 parameter is on. This means that string functions like substr() work properly on multi-byte languages, now. Patch By Max Kanat-Alexander r=wurblzap, a=mkanat --- Bugzilla/CGI.pm | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'Bugzilla/CGI.pm') diff --git a/Bugzilla/CGI.pm b/Bugzilla/CGI.pm index ef2cb70f5..3498b3c70 100644 --- a/Bugzilla/CGI.pm +++ b/Bugzilla/CGI.pm @@ -233,6 +233,27 @@ sub header { return $self->SUPER::header(@_) || ""; } +# CGI.pm is not utf8-aware and passes data as bytes instead of UTF-8 strings. +sub param { + my $self = shift; + if (Bugzilla->params->{'utf8'} && scalar(@_) == 1) { + if (wantarray) { + return map { _fix_utf8($_) } $self->SUPER::param(@_); + } + else { + return _fix_utf8(scalar $self->SUPER::param(@_)); + } + } + return $self->SUPER::param(@_); +} + +sub _fix_utf8 { + my $input = shift; + # The is_utf8 is here in case CGI gets smart about utf8 someday. + utf8::decode($input) if defined $input && !utf8::is_utf8($input); + return $input; +} + # The various parts of Bugzilla which create cookies don't want to have to # pass them around to all of the callers. Instead, store them locally here, # and then output as required from |header|. -- cgit v1.2.3-24-g4f1b