annotate debian/patches/12_optional_xml_elements @ 9:0f248ad86f9f 1.1.29.e2

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