| 1 | package Net::UPnP::AV::RSS; | ||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use Encode qw(decode FB_CROAK); | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||
| 7 | 82 | ▶ | sub _text { | ||||||||||||||||||||||||||||
|
Subroutine
_text: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||
| 8 | 82 | my ($value) = @_; | |||||||||||||||||||||||||||||
| 9 | 82 | ▶ | return '' unless defined $value; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 10 | 82 | ▶ | return $value if utf8::is_utf8($value); | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 11 | 62 | return decode('UTF-8', $value, FB_CROAK); | |||||||||||||||||||||||||||||
| 12 | } | ||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||
| 14 | # XML 1.0 text and quoted attributes share these escaping requirements. | ||||||||||||||||||||||||||||||
| 15 | # Invalid XML characters have no representable numeric entity: replace them. | ||||||||||||||||||||||||||||||
| 16 | 63 | ▶ | sub _escape { | ||||||||||||||||||||||||||||
|
Subroutine
_escape: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 17 | 63 | my ($value) = @_; | |||||||||||||||||||||||||||||
| 18 | 63 | $value = _text($value); | |||||||||||||||||||||||||||||
| 19 | 63 | $value =~ s/[^\x09\x0a\x0d\x20-\x{d7ff}\x{e000}-\x{fffd}\x{10000}-\x{10ffff}]/?/g; | |||||||||||||||||||||||||||||
| 20 | 63 | $value =~ s/&/&/g; | |||||||||||||||||||||||||||||
| 21 | 63 | $value =~ s/</</g; | |||||||||||||||||||||||||||||
| 22 | 63 | $value =~ s/>/>/g; | |||||||||||||||||||||||||||||
| 23 | 63 | $value =~ s/"/"/g; | |||||||||||||||||||||||||||||
| 24 | 63 | $value =~ s/'/'/g; | |||||||||||||||||||||||||||||
| 25 | 63 | $value =~ s/\r/ /g; | |||||||||||||||||||||||||||||
| 26 | 63 | $value =~ s/\n/ /g; | |||||||||||||||||||||||||||||
| 27 | 63 | $value =~ s/\t/	/g; | |||||||||||||||||||||||||||||
| 28 | 63 | return $value; | |||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||
| 31 | 27 | ▶ | sub _entity { | ||||||||||||||||||||||||||||
|
Subroutine
_entity: called CC=8 SCAR=20.9
| |||||||||||||||||||||||||||||||
| 32 | 27 | my ($entity) = @_; | |||||||||||||||||||||||||||||
| 33 | 27 | my %named = (amp => '&', lt => '<', gt => '>', quot => '"', apos => "'"); | |||||||||||||||||||||||||||||
| 34 | 27 | ▶ | return $named{$entity} if exists $named{$entity}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 35 | 10 | my $hex = $entity =~ s/\A#x//i; | |||||||||||||||||||||||||||||
| 36 | 10 | $entity =~ s/\A#//; | |||||||||||||||||||||||||||||
| 37 | 10 | $entity =~ s/\A0+//; | |||||||||||||||||||||||||||||
| 38 | 10 | ▶ | return '?' if length($entity) > ($hex ? 6 : 7); | ||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||
| 39 | 8 | ▶ | my $number = $hex ? hex($entity || '0') : 0 + ($entity || '0'); | ||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%2/4
$entity || '0'
$entity || '0'
MC/DC0%0/1
$entity || '0'
$entity
MC/DC0%0/1
$entity || '0'
$entity
Truth table50%1/2
A
A= $entity
Truth table50%1/2
A
A= $entity
| |||||||||||||||||||||||||||||||
| 40 | 8 | ▶ | return '?' if $number > 0x10ffff; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 41 | 8 | return chr($number); | |||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||
| 44 | 3 | ▶ | sub header { | ||||||||||||||||||||||||||||
|
Subroutine
header: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 45 | 3 | my (%args) = @_; | |||||||||||||||||||||||||||||
| 46 | my ($title, $language, $description, $link) = | ||||||||||||||||||||||||||||||
| 47 | 3 | map { _escape($args{$_}) } qw(title language description link); | |||||||||||||||||||||||||||||
| 48 | 3 | return <<"RSS"; | |||||||||||||||||||||||||||||
| 49 | <?xml version="1.0" encoding="utf-8"?> | ||||||||||||||||||||||||||||||
| 50 | <rss xmlns:itunes="http://www.itunes.com/DTDs/Podcast-1.0.dtd" version="2.0"> | ||||||||||||||||||||||||||||||
| 51 | <channel> | ||||||||||||||||||||||||||||||
| 52 | <title>$title</title> | ||||||||||||||||||||||||||||||
| 53 | <language>$language</language> | ||||||||||||||||||||||||||||||
| 54 | <description>$description</description> | ||||||||||||||||||||||||||||||
| 55 | <link>$link</link> | ||||||||||||||||||||||||||||||
| 56 | RSS | ||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||
| 59 | 19 | ▶ | sub item { | ||||||||||||||||||||||||||||
|
Subroutine
item: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 60 | 19 | my (%args) = @_; | |||||||||||||||||||||||||||||
| 61 | # ContentDirectory titles retain one layer of DIDL entities after the | ||||||||||||||||||||||||||||||
| 62 | # outer SOAP Result is decoded. Decode exactly once, then escape as data. | ||||||||||||||||||||||||||||||
| 63 | 19 | my $title = _text($args{title}); | |||||||||||||||||||||||||||||
| 64 | 17 | $title =~ s/&(#x[0-9a-fA-F]+|#[0-9]+|amp|lt|gt|quot|apos);/_entity($1)/ge; | |||||||||||||||||||||||||||||
| 65 | 17 | $title = _escape($title); | |||||||||||||||||||||||||||||
| 66 | 17 | my $link = _escape($args{link}); | |||||||||||||||||||||||||||||
| 67 | 17 | my $size = _escape($args{size}); | |||||||||||||||||||||||||||||
| 68 | 17 | return <<"RSS"; | |||||||||||||||||||||||||||||
| 69 | <item> | ||||||||||||||||||||||||||||||
| 70 | <title>$title</title> | ||||||||||||||||||||||||||||||
| 71 | <guid isPermalink="false">$link</guid> | ||||||||||||||||||||||||||||||
| 72 | <enclosure url="$link" length="$size" type="video/mp4" /> | ||||||||||||||||||||||||||||||
| 73 | </item> | ||||||||||||||||||||||||||||||
| 74 | RSS | ||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||
| 77 | 2 | 1; | |||||||||||||||||||||||||||||