From: short <> Date: Sat, 10 Sep 2005 07:41:28 +0000 (+0000) Subject: More foolproof handling of: &CGI::charset X-Git-Url: https://git.jankratochvil.net/?p=MyWeb.git;a=commitdiff_plain;h=ce244b8d7c56fbb7d4b1707ab13c8426eed57216 More foolproof handling of: &CGI::charset --- diff --git a/Web.pm b/Web.pm index 872224e..3d24a95 100644 --- a/Web.pm +++ b/Web.pm @@ -96,8 +96,7 @@ BEGIN } use WebConfig; # see also below: Wuse 'WebConfig'; -require CGI; # for &escapeHTML -CGI::charset("utf-8"); # Prevent &CGI::escapeHTML breaking utf-8 like \xC4\x9B eq \x{11B} +require CGI; require Image::Size; # for &imgsize use File::Basename; # &basename use Carp qw(cluck confess); @@ -254,7 +253,9 @@ my($text)=@_; # Use &eval to prevent: Global $r object is not available. Set:\n\tPerlOptions +GlobalRequest\nin ... # CGI requires valid "r": check it beforehand here. confess "Calling dynamic URL generator from a static code" if !eval { Apache2::RequestUtil->request(); }; - # See also somewhere else: CGI::charset("utf-8"); + # Prevent &CGI::escapeHTML breaking utf-8 strings like: \xC4\x9B eq \x{11B} + do { cluck "charset==$_" if $_ && $_ ne "utf-8"; } for CGI::charset(); + CGI::charset("utf-8"); return CGI::escapeHTML($text); }