From: Moritz Bunkus Date: Tue, 10 May 2011 14:05:38 +0000 (+0200) Subject: HTML.uri() muss Strings zuerst von Perls internem Encoding nach UTF-8 wandeln X-Git-Tag: release-2.6.3~25^2~70 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=e257fa36cfb1ff40a451d8e2ce1f71e477701640;p=kivitendo-erp.git HTML.uri() muss Strings zuerst von Perls internem Encoding nach UTF-8 wandeln Fix für Bug 1641. --- diff --git a/SL/Dispatcher.pm b/SL/Dispatcher.pm index 909433ebd..c1f31a4ef 100644 --- a/SL/Dispatcher.pm +++ b/SL/Dispatcher.pm @@ -19,6 +19,7 @@ use SL::Locale; use SL::Common; use SL::Form; use SL::Helper::DateTime; +use SL::Template::Plugin::HTMLFixes; use List::Util qw(first); use File::Basename; diff --git a/SL/Template/Plugin/HTMLFixes.pm b/SL/Template/Plugin/HTMLFixes.pm new file mode 100644 index 000000000..3f328a842 --- /dev/null +++ b/SL/Template/Plugin/HTMLFixes.pm @@ -0,0 +1,29 @@ +package SL::Template::Plugin::HTMLFixes; + +use Template::Plugin::HTML; + +1; + +package Template::Plugin::HTML; + +use strict; + +use Encode; + +# Replacement for Template::Plugin::HTML::url. + +# Strings in Lx-Office are stored in Perl's internal encoding but have +# to be output as UTF-8. A normal regex replace doesn't do that +# creating invalid UTF-8 characters upon URL-unescaping. + +# The only addition is the "Encode::encode()" line. + +sub url { + my ($self, $text) = @_; + return undef unless defined $text; + $text = Encode::encode('utf-8-strict', $text) if $::locale && $::locale->is_utf8; + $text =~ s/([^a-zA-Z0-9_.-])/uc sprintf("%%%02x",ord($1))/eg; + return $text; +} + +1;