Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision e257fa36

Von Moritz Bunkus vor mehr als 13 Jahren hinzugefügt

  • ID e257fa36cfb1ff40a451d8e2ce1f71e477701640
  • Vorgänger b28b621e
  • Nachfolger 4d59fd5d

HTML.uri() muss Strings zuerst von Perls internem Encoding nach UTF-8 wandeln

Fix für Bug 1641.

Unterschiede anzeigen:

SL/Dispatcher.pm
19 19
use SL::Common;
20 20
use SL::Form;
21 21
use SL::Helper::DateTime;
22
use SL::Template::Plugin::HTMLFixes;
22 23
use List::Util qw(first);
23 24
use File::Basename;
24 25

  
SL/Template/Plugin/HTMLFixes.pm
1
package SL::Template::Plugin::HTMLFixes;
2

  
3
use Template::Plugin::HTML;
4

  
5
1;
6

  
7
package Template::Plugin::HTML;
8

  
9
use strict;
10

  
11
use Encode;
12

  
13
# Replacement for Template::Plugin::HTML::url.
14

  
15
# Strings in Lx-Office are stored in Perl's internal encoding but have
16
# to be output as UTF-8. A normal regex replace doesn't do that
17
# creating invalid UTF-8 characters upon URL-unescaping.
18

  
19
# The only addition is the "Encode::encode()" line.
20

  
21
sub url {
22
    my ($self, $text) = @_;
23
    return undef unless defined $text;
24
    $text =  Encode::encode('utf-8-strict', $text) if $::locale && $::locale->is_utf8;
25
    $text =~ s/([^a-zA-Z0-9_.-])/uc sprintf("%%%02x",ord($1))/eg;
26
    return $text;
27
}
28

  
29
1;

Auch abrufbar als: Unified diff