| 1 | # -*- perl -*- | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | # | ||||||||||||||||||||
| 4 | # $Id: Escape.pm,v 1.2 2004/12/13 23:19:39 eserte Exp $ | ||||||||||||||||||||
| 5 | # Author: Slaven Rezic | ||||||||||||||||||||
| 6 | # | ||||||||||||||||||||
| 7 | # Copyright (C) 2004 Slaven Rezic. All rights reserved. | ||||||||||||||||||||
| 8 | # This package is free software; you can redistribute it and/or | ||||||||||||||||||||
| 9 | # modify it under the same terms as Perl itself. | ||||||||||||||||||||
| 10 | # | ||||||||||||||||||||
| 11 | # Mail: eserte@users.sourceforge.net | ||||||||||||||||||||
| 12 | # WWW: http://www.sf.net/projects/we-framework/ | ||||||||||||||||||||
| 13 | # | ||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | package WE::Util::Escape; | ||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 18 | 1 | ▶ | use vars qw($VERSION); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 19 | 1 | $VERSION = sprintf("%d.%02d", q$Revision: 1.2 $ =~ /(\d+)\.(\d+)/); | |||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | 1 | ▶ | use vars qw(%uri_escapes); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 22 | 1 | for (0..255) { | |||||||||||||||||||
| 23 | 256 | $uri_escapes{chr($_)} = sprintf("%%%02X", $_); | |||||||||||||||||||
| 24 | } | ||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | 0 | ▶ | sub uri_escape { | ||||||||||||||||||
|
Subroutine
uri_escape: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||
| 27 | 0 | my($text) = @_; | |||||||||||||||||||
| 28 | 0 | ▶ | return undef unless defined $text; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 29 | # Default unsafe characters. RFC 2732 ^(uric - reserved) | ||||||||||||||||||||
| 30 | 0 | ▶ | $text =~ s/([^A-Za-z0-9\-_.!~*'()])/$uri_escapes{$1} || sprintf "%%u%04x", ord($1)/ge; | ||||||||||||||||||
|
Condition0%0/3
$WE::Util::Escape::uri_escapes{$1} || sprintf('%%u%04x', ord $1)
MC/DC0%0/2
$WE::Util::Escape::uri_escapes{$1} || sprintf('%%u%04x', ord $1)
$WE::Util::Escape::uri_escapes{$1}
sprintf('%%u%04x', ord $1)
Truth table0%0/3
A || B
A= $WE::Util::Escape::uri_escapes{$1}B= sprintf('%%u%04x', ord $1)
| |||||||||||||||||||||
| 31 | 0 | $text; | |||||||||||||||||||
| 32 | } | ||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | 1 | 1; | |||||||||||||||||||