File Coverage

blib/lib/XML/Liberal/Remedy/NestedCDATA.pm
Criterion Covered Total %
statement 16 16 100.0
branch 3 4 75.0
condition n/a
subroutine 3 3 100.0
pod 0 1 0.0
total 22 24 91.6


line stmt bran cond sub pod time code
1             package XML::Liberal::Remedy::NestedCDATA;
2 5     5   1998 use strict;
  5         8  
  5         123  
3              
4 5     5   1759 use HTML::Entities qw( encode_entities );
  5         21832  
  5         1014  
5              
6             sub apply {
7 96     96 0 142 my $class = shift;
8 96         180 my($driver, $error, $xml_ref) = @_;
9              
10 96 100       211 return 0 if $error->message !~ /^parser error : Opening and ending tag mismatch:/;
11              
12 21         461 while ($$xml_ref =~ /(?<= )/xmsg) {
13 5         28 my ($cdata, $start, $end) = ($1, $-[1], $+[1]);
14 5 50       22 next if $cdata !~ /
15 5         18 my $escaped = encode_entities($cdata, '<>&');
16 5         1116 substr($$xml_ref, $start, $end - $start) = "]]>$escaped
17 5         19 return 1;
18             }
19              
20 16         45 return 0;
21             }
22              
23             1;