Thread htmlspecialchars & Umlaute in Dtanebank speichern (13 answers)
Opened by jonyder123 at 2008-01-04 13:15

Froschpopo
 2008-01-04 13:51
#104392 #104392
User since
2003-08-15
2653 Artikel
BenutzerIn
[default_avatar]
da ich meistens sowieso mit CGI.pm arbeite, nehme ich meistens escapeHTML. Warum doppelt gemoppelt?
Hier ein Auszug aus escapeHTML:
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
sub escapeHTML {
         # hack to work around  earlier hacks
         push @_,$_[0] if @_==1 && $_[0] eq 'CGI';
         my ($self,$toencode,$newlinestoo) = CGI::self_or_default(@_);
         return undef unless defined($toencode);
         return $toencode if ref($self) && !$self->{'escape'};
         $toencode =~ s{&}{&}gso;
         $toencode =~ s{<}{&lt;}gso;
         $toencode =~ s{>}{&gt;}gso;
         if ($DTD_PUBLIC_IDENTIFIER =~ /[^X]HTML 3\.2/i) {
             # $quot; was accidentally omitted from the HTML 3.2 DTD -- see
             # <http://validator.w3.org/docs/errors.html#bad-entity> /
             # <http://lists.w3.org/Archives/Public/www-html/1997Mar/0003.html>.
             $toencode =~ s{"}{&#34;}gso;
         }
         else {
             $toencode =~ s{"}{&quot;}gso;
         }
         my $latin = uc $self->{'.charset'} eq 'ISO-8859-1' ||
                     uc $self->{'.charset'} eq 'WINDOWS-1252';
         if ($latin) {  # bug in some browsers
                $toencode =~ s{'}{&#39;}gso;
                $toencode =~ s{\x8b}{&#8249;}gso;
                $toencode =~ s{\x9b}{&#8250;}gso;
                if (defined $newlinestoo && $newlinestoo) {
                     $toencode =~ s{\012}{&#10;}gso;
                     $toencode =~ s{\015}{&#13;}gso;
                }
         }
         return $toencode;
}


ist also auch nix weltbewegendes, aber genĂ¼gen tuts trotzdem voll und ganz.

View full thread htmlspecialchars & Umlaute in Dtanebank speichern