| 1 | 33 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 2 | 33 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | package Net::SAML2::XML::Util; | ||
| 4 | 33 | our $VERSION = '0.89'; # VERSION | |
| 5 | |||
| 6 | 33 | ▶ | use XML::LibXML; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | |||
| 8 | # use 'our' on v5.6.0 | ||
| 9 | 33 | ▶ | use vars qw($VERSION @EXPORT_OK %EXPORT_TAGS $DEBUG); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | |||
| 11 | 33 | $DEBUG = 0; | |
| 12 | |||
| 13 | # We are exporting functions | ||
| 14 | 33 | ▶ | use base qw/Exporter/; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 15 | |||
| 16 | # Export list - to allow fine tuning of export table | ||
| 17 | 33 | @EXPORT_OK = qw( no_comments ); | |
| 18 | |||
| 19 | # ABSTRACT: XML Util class | ||
| 20 | |||
| 21 | |||
| 22 | |||
| 23 | 97 | ▶ | sub no_comments { |
|
Subroutine
no_comments: called CC=2 SCAR=6.9
Pod
documented
| |||
| 24 | 97 | my $xml = shift; | |
| 25 | |||
| 26 | # Remove comments from XML to mitigate XML comment auth bypass | ||
| 27 | 97 | my $dom = XML::LibXML->load_xml( | |
| 28 | string => $xml, | ||
| 29 | no_network => 1, | ||
| 30 | load_ext_dtd => 0, | ||
| 31 | expand_entities => 0 | ||
| 32 | ); | ||
| 33 | |||
| 34 | 97 | for my $comment_node ($dom->findnodes('//comment()')) { | |
| 35 | 8 | $comment_node->parentNode->removeChild($comment_node); | |
| 36 | } | ||
| 37 | |||
| 38 | 97 | return $dom; | |
| 39 | } | ||
| 40 | |||
| 41 | 33 | 1; | |
| 42 | |||
| 43 | __END__ | ||