WE/Util/Escape.pm

filter: Statementstmt 72.2% 13 / 18 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 75.0% 3 / 4 Podpod 0.0% 0 / 1 totaltotal 53.3% 16 / 30 CC 3 SCAR 18.7
CC
3
Cov
57%
uri_escape
12.0
BEGIN
1.0
BEGIN
1.0
CRAP 6.5
« WE_Frontend/TextLayouter.pm ↑ Summary WebEditor/OldFeatures/SystemExplorer.pm »
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
BranchTrueFalseTotal
unless defined $text 0 0 0
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)
l!l&&r!l&&!r
000
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)
ABresult
1X1
011
000
31 0 $text;
32 }
33  
34 1 1;
« WE_Frontend/TextLayouter.pm ↑ Summary WebEditor/OldFeatures/SystemExplorer.pm »