comparison debian/patches/12_optional_xml_elements @ 4:c5749e43b1d7

Adding debian files (to original 1.1.29)
author Peter Gervai <grin@grin.hu>
date Wed, 15 Oct 2008 23:35:35 +0200
parents
children
comparison
equal deleted inserted replaced
0:a84c32f131df 4:c5749e43b1d7
1 #! /bin/sh /usr/share/dpatch/dpatch-run
2 ## 12_optional_xml_elements.dpatch by Martin Michlmayr <tbm@cyrius.com>
3 ##
4 ## DP: Make XML elements optional and check whether the XML files are
5 ## DP: valid bins files [#308338]
6
7 @DPATCH@
8 --- bins-1.1.29.orig/bins
9 +++ bins-1.1.29/bins
10 @@ -3899,10 +3899,14 @@
11 if (-e $descFile) {
12 beVerboseN(" Reading desc file $descFile.", 3);
13 $document = getXMLAsGrove($descFile);
14 - %descHash = getDescXML($document, $configHash);
15 - #$descHash{descFileName} = uri_escape($descFile, '^-A-Za-z0-9/_\.');
16 - $configHash = getConfigXML($document, '/image/bins', $configHash);
17 - %exifHash = getExifXML($document, \@priorityList);
18 + if (! $document->at_path("/image")) {
19 + beVerboseN("Description file $descFile has no <image> element, ignoring.", 1);
20 + } else {
21 + %descHash = getDescXML($document, $configHash) if $document->at_path("/image/description");
22 + #$descHash{descFileName} = uri_escape($descFile, '^-A-Za-z0-9/_\.');
23 + $configHash = getConfigXML($document, '/image/bins', $configHash) if $document->at_path("/image/bins");
24 + %exifHash = getExifXML($document, \@priorityList) if $document->at_path("/image/exif");
25 + }
26 } else {
27 $descHash{descFileName} = "";
28 }
29 @@ -4541,6 +4545,10 @@
30 beVerboseN("Reading album description file '$descFile'...", 3);
31
32 my $document = getXMLAsGrove($descFile);
33 + if (! $document->at_path("/album")) {
34 + beVerboseN("Description file $descFile has no <album> element, ignoring.", 1);
35 + return $configHash;
36 + }
37 # I have to do that, don't ask me why...
38
39 #$XML::UM::ENCDIR="/usr/lib/perl5/XML/Parser/";
40 @@ -4548,37 +4556,40 @@
41 # Encoding => 'ISO-8859-9',
42 # EncodeUnmapped => \&XML::UM::encode_unmapped_dec);
43
44 - $configHash = getConfigXML($document, "/album/bins", $configHash);
45 + $configHash = getConfigXML($document, "/album/bins", $configHash) if
46 + $document->at_path("/album/bins");
47
48 - foreach my $element
49 - (@{$document->at_path('/album/description')->{Contents}}) {
50 - if (UNIVERSAL::isa($element, 'XML::Grove::Element') && $element->{Name} eq "field") {
51 - $fieldName = $element->{Attributes}{'name'};
52 - $fieldValue = "";
53 - if (grep (/^$fieldName$/, @AlbumFieldNames)) {
54 - beVerbose(" Reading field '$fieldName':", 3);
55 - foreach my $characters (@{$element->{Contents}}) {
56 - $fieldValue .= $characters->as_canon_xml();
57 - }
58 - #if ($fieldName ne "shortdesc" && $fieldName ne "longdesc"){
59 - # $fieldValue = decode_entities($fieldValue);
60 - #}
61 - if ($fieldName eq "sampleimage"){
62 - $fieldValue =
63 - trimWhiteSpace(decode_entities($fieldValue));
64 - beVerbose("'".$fieldValue."'\n", 3);
65 - }else{
66 - $fieldValue =
67 - trimWhiteSpace(decode_entities(xml2html($fieldValue)));
68 - beVerbose("'".$fieldValue."'\n", 3);
69 + if ($document->at_path("/album/description")) {
70 + foreach my $element
71 + (@{$document->at_path('/album/description')->{Contents}}) {
72 + if (UNIVERSAL::isa($element, 'XML::Grove::Element') && $element->{Name} eq "field") {
73 + $fieldName = $element->{Attributes}{'name'};
74 + $fieldValue = "";
75 + if (grep (/^$fieldName$/, @AlbumFieldNames)) {
76 + beVerbose(" Reading field '$fieldName':", 3);
77 + foreach my $characters (@{$element->{Contents}}) {
78 + $fieldValue .= $characters->as_canon_xml();
79 + }
80 + #if ($fieldName ne "shortdesc" && $fieldName ne "longdesc"){
81 + # $fieldValue = decode_entities($fieldValue);
82 + #}
83 + if ($fieldName eq "sampleimage"){
84 + $fieldValue =
85 + trimWhiteSpace(decode_entities($fieldValue));
86 + beVerbose("'".$fieldValue."'\n", 3);
87 + }else{
88 + $fieldValue =
89 + trimWhiteSpace(decode_entities(xml2html($fieldValue)));
90 + beVerbose("'".$fieldValue."'\n", 3);
91 + }
92 + # $fieldValue = $encode->(trimWhiteSpace($fieldValue));
93 + $hash->{$fieldName} = $fieldValue;
94 + } else {
95 + beVerboseN(" Ignoring unknown field '$fieldName'.", 3);
96 }
97 - # $fieldValue = $encode->(trimWhiteSpace($fieldValue));
98 - $hash->{$fieldName} = $fieldValue;
99 - } else {
100 - beVerboseN(" Ignoring unknown field '$fieldName'.", 3);
101 }
102 }
103 - }
104 + }
105 return $configHash;
106 }
107