diff options
author | mkanat%bugzilla.org <> | 2007-11-23 13:58:33 +0100 |
---|---|---|
committer | mkanat%bugzilla.org <> | 2007-11-23 13:58:33 +0100 |
commit | 9f0310bf8c0821347699b434f659eb52decabf87 (patch) | |
tree | 31153ecb72f2b57a9bb3daf638cc4e1152f8a0b0 /Bugzilla/CGI.pm | |
parent | 8ab75a83c21606ad77a38c05057f886011fa0451 (diff) | |
download | bugzilla-9f0310bf8c0821347699b434f659eb52decabf87.tar.gz bugzilla-9f0310bf8c0821347699b434f659eb52decabf87.tar.xz |
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 <mkanat@bugzilla.org> r=wurblzap, a=mkanat
Diffstat (limited to 'Bugzilla/CGI.pm')
-rw-r--r-- | Bugzilla/CGI.pm | 21 |
1 files changed, 21 insertions, 0 deletions
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|. |