Changeset 16900

Show
Ignore:
Timestamp:
19.08.2008 14:32:48 (11 years ago)
Author:
ak19
Message:

1. URL_encode method now only encodes urls if they are not already encoded (prevents double encoding). 2. new subroutine is_url_encoded returns true if the given string is already url_encoded

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/perllib/unicode.pm

    r16673 r16900  
    578578sub url_encode { 
    579579    my ($text) = @_; 
    580     $text =~ s/([^A-Z0-9\.\-\_])/sprintf("%%%02X", ord($1))/iseg; 
    581  
     580    if (!&is_url_encoded($text)) { 
     581    print STDERR "*** not percent encoded yet\n"; 
     582    $text =~ s/([^A-Z0-9\.\-\_])/sprintf("%%%02X", ord($1))/iseg; 
     583    } 
    582584    return $text; 
    583585} 
     
    588590    $text =~ s/\%([A-F0-9]{2})/pack('C', hex($1))/ige; 
    589591    return $text; 
     592} 
     593 
     594sub is_url_encoded { 
     595    my ($text) = @_; 
     596    return ($text =~ m/\%([A-F0-9]{2})/); 
    590597} 
    591598