From: Dobrica Pavlinusic Date: Tue, 15 Nov 2005 14:30:26 +0000 (+0000) Subject: r8880@llin: dpavlin | 2005-11-14 19:16:05 +0100 X-Git-Url: http://git.rot13.org/?p=webpac2;a=commitdiff_plain;h=ab81a94b8f9f777ee405de00b9c8a63b29e14e41 r8880@llin: dpavlin | 2005-11-14 19:16:05 +0100 fix character encoding issues due to JavaScript which returns %uxxxx encoded characters git-svn-id: svn+ssh://mjesec/home/dpavlin/svn/webpac2/trunk@58 07558da8-63fa-0310-ba24-9fe276d99e06 --- diff --git a/web/browse.cgi b/web/browse.cgi index 0a67b96..5eeba84 100755 --- a/web/browse.cgi +++ b/web/browse.cgi @@ -48,10 +48,10 @@ if ($q->path_info =~ m#xml#) { if (@ds && $#ds > 0) { print qq{ - }, $out->apply( + }, $iconv_utf8->convert( $out->apply( template => $template, data => \@ds, - ), qq{ + ) ), qq{ @@ -88,9 +88,15 @@ if ($q->path_info =~ m#xml#) { if ($q->param('save_template')) { - my $tmpl = $q->param('tt_template') || die "no template?"; + my $tmpl = $iconv_loc->convert( $q->param('tt_template') ) || die "no template?"; + sub _conv_js { + my $t = shift || return; + return $iconv_loc->convert(chr(hex($t))); + } + $tmpl =~ s/%u([a-fA-F0-9]{4})/_conv_js($1)/gex; + my $tmpl_file = $out->{'include_path'} . '/' . $template; - write_file($tmpl_file . '.new', $iconv_loc->convert($tmpl)) || die "can't save $tmpl_file: $!"; + write_file($tmpl_file . '.new', $tmpl) || die "can't save $tmpl_file: $!"; rename $tmpl_file . '.new', $tmpl_file || die "can't rename to $tmpl_file: $!"; print qq{