summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Util.pm
diff options
context:
space:
mode:
authormkanat%bugzilla.org <>2007-11-23 13:58:33 +0100
committermkanat%bugzilla.org <>2007-11-23 13:58:33 +0100
commit9f0310bf8c0821347699b434f659eb52decabf87 (patch)
tree31153ecb72f2b57a9bb3daf638cc4e1152f8a0b0 /Bugzilla/Util.pm
parent8ab75a83c21606ad77a38c05057f886011fa0451 (diff)
downloadbugzilla-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/Util.pm')
-rw-r--r--Bugzilla/Util.pm6
1 files changed, 6 insertions, 0 deletions
diff --git a/Bugzilla/Util.pm b/Bugzilla/Util.pm
index ffc2af95a..144fb87c1 100644
--- a/Bugzilla/Util.pm
+++ b/Bugzilla/Util.pm
@@ -185,6 +185,8 @@ sub html_light_quote {
# This originally came from CGI.pm, by Lincoln D. Stein
sub url_quote {
my ($toencode) = (@_);
+ utf8::encode($toencode) # The below regex works only on bytes
+ if Bugzilla->params->{'utf8'} && utf8::is_utf8($toencode);
$toencode =~ s/([^a-zA-Z0-9_\-.])/uc sprintf("%%%02x",ord($1))/eg;
return $toencode;
}
@@ -206,6 +208,10 @@ sub xml_quote {
return $var;
}
+# This function must not be relied upon to return a valid string to pass to
+# the DB or the user in UTF-8 situations. The only thing you can rely upon
+# it for is that if you url_decode a string, it will url_encode back to the
+# exact same thing.
sub url_decode {
my ($todecode) = (@_);
$todecode =~ tr/+/ /; # pluses become spaces