| 1 | # Copyright (c) 1998-2005 by Jonathan Swartz. All rights reserved. | ||||||||||
| 2 | # This program is free software; you can redistribute it and/or modify it | ||||||||||
| 3 | # under the same terms as Perl itself. | ||||||||||
| 4 | |||||||||||
| 5 | # | ||||||||||
| 6 | # A library of escape subroutines to be used for substitution escaping | ||||||||||
| 7 | # | ||||||||||
| 8 | |||||||||||
| 9 | package HTML::Mason::Escapes; | ||||||||||
| 10 | 33 | $HTML::Mason::Escapes::VERSION = '1.60'; | |||||||||
| 11 | 33 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 33 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | 33 | ▶ | use HTML::Entities (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | |||||||||||
| 16 | |||||||||||
| 17 | 33 | my %html_escape = ('&' => '&', '>'=>'>', '<'=>'<', '"'=>'"'); | |||||||||
| 18 | 33 | my $html_escape = qr/([&<>"])/; | |||||||||
| 19 | |||||||||||
| 20 | sub basic_html_escape | ||||||||||
| 21 | 34 | ▶ | { | ||||||||
|
Subroutine
basic_html_escape: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 22 | 34 | ▶ | return unless defined ${ $_[0] }; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | |||||||||||
| 24 | 34 | ${ $_[0] } =~ s/$html_escape/$html_escape{$1}/mg; | |||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | sub html_entities_escape | ||||||||||
| 28 | 16 | ▶ | { | ||||||||
|
Subroutine
html_entities_escape: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 29 | 16 | ▶ | return unless defined ${ $_[0] }; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 30 | |||||||||||
| 31 | 16 | HTML::Entities::encode_entities( ${ $_[0] } ); | |||||||||
| 32 | } | ||||||||||
| 33 | |||||||||||
| 34 | sub url_escape | ||||||||||
| 35 | 5 | ▶ | { | ||||||||
|
Subroutine
url_escape: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 36 | 5 | ▶ | return unless defined ${ $_[0] }; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 37 | |||||||||||
| 38 | 33 | ▶ | use bytes; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 39 | 5 | ${ $_[0] } =~ s/([^a-zA-Z0-9_.-])/uc sprintf("%%%02x",ord($1))/eg; | |||||||||
| 40 | } | ||||||||||
| 41 | |||||||||||
| 42 | |||||||||||
| 43 | 33 | 1; | |||||||||
| 44 | |||||||||||
| 45 | __END__ | ||||||||||