File Coverage

blib/lib/XML/Liberal/Remedy/NestedCDATA.pm
Criterion Covered Total %
statement 6 16 37.5
branch 0 4 0.0
condition n/a
subroutine 2 3 66.6
pod 0 1 0.0
total 8 24 33.3


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