r90 - in trunk: . patches
Martin Michlmayr
tbm at costa.debian.org
Fri Nov 4 19:03:37 UTC 2005
Author: tbm
Date: 2005-11-04 19:03:14 +0000 (Fri, 04 Nov 2005)
New Revision: 90
Added:
trunk/patches/12_optional_xml_elements.dpatch
Modified:
trunk/changelog
trunk/patches/00list
Log:
Make XML elements optional and check whether the XML files are valid bins
files. Closes: #308338.
Modified: trunk/changelog
===================================================================
--- trunk/changelog 2005-11-04 18:18:59 UTC (rev 89)
+++ trunk/changelog 2005-11-04 19:03:14 UTC (rev 90)
@@ -11,6 +11,9 @@
for movie files. Closes: #334064.
* debian/patches/11_check_template_style.dpatch: Check if the specified
template style exists before processing images. Closes: #308114.
+ * debian/patches/12_optional_xml_elements.dpatch: Make XML elements
+ optional and check whether the XML files are valid bins files.
+ Closes: #308338.
-- Martin Michlmayr <tbm at cyrius.com> Sat, 15 Oct 2005 20:49:21 +0100
Modified: trunk/patches/00list
===================================================================
--- trunk/patches/00list 2005-11-04 18:18:59 UTC (rev 89)
+++ trunk/patches/00list 2005-11-04 19:03:14 UTC (rev 90)
@@ -6,3 +6,4 @@
09_fix_wrong_relpath
10_symlinks_movies
11_check_template_style
+12_optional_xml_elements
Added: trunk/patches/12_optional_xml_elements.dpatch
===================================================================
--- trunk/patches/12_optional_xml_elements.dpatch 2005-11-04 18:18:59 UTC (rev 89)
+++ trunk/patches/12_optional_xml_elements.dpatch 2005-11-04 19:03:14 UTC (rev 90)
@@ -0,0 +1,108 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 12_optional_xml_elements.dpatch by Martin Michlmayr <tbm at cyrius.com>
+##
+## DP: Make XML elements optional and check whether the XML files are
+## DP: valid bins files [#308338]
+
+ at DPATCH@
+--- bins.orig/bins 2005-10-15 16:02:07.000000000 +0100
++++ bins.new/bins 2005-11-04 18:54:34.000000000 +0000
+@@ -3881,10 +3881,14 @@
+ if (-e $descFile) {
+ beVerboseN(" Reading desc file $descFile.", 3);
+ $document = getXMLAsGrove($descFile);
+- %descHash = getDescXML($document, $configHash);
+- #$descHash{descFileName} = uri_escape($descFile, '^-A-Za-z0-9/_\.');
+- $configHash = getConfigXML($document, '/image/bins', $configHash);
+- %exifHash = getExifXML($document, \@priorityList);
++ if (! $document->at_path("/image")) {
++ beVerboseN("Description file $descFile has no <image> element, ignoring.", 1);
++ } else {
++ %descHash = getDescXML($document, $configHash) if $document->at_path("/image/description");
++ #$descHash{descFileName} = uri_escape($descFile, '^-A-Za-z0-9/_\.');
++ $configHash = getConfigXML($document, '/image/bins', $configHash) if $document->at_path("/image/bins");
++ %exifHash = getExifXML($document, \@priorityList) if $document->at_path("/image/exif");
++ }
+ } else {
+ $descHash{descFileName} = "";
+ }
+@@ -4523,6 +4527,10 @@
+ beVerboseN("Reading album description file '$descFile'...", 3);
+
+ my $document = getXMLAsGrove($descFile);
++ if (! $document->at_path("/album")) {
++ beVerboseN("Description file $descFile has no <album> element, ignoring.", 1);
++ return $configHash;
++ }
+ # I have to do that, don't ask me why...
+
+ #$XML::UM::ENCDIR="/usr/lib/perl5/XML/Parser/";
+@@ -4530,37 +4538,40 @@
+ # Encoding => 'ISO-8859-9',
+ # EncodeUnmapped => \&XML::UM::encode_unmapped_dec);
+
+- $configHash = getConfigXML($document, "/album/bins", $configHash);
++ $configHash = getConfigXML($document, "/album/bins", $configHash) if
++ $document->at_path("/album/bins");
+
+- foreach my $element
+- (@{$document->at_path('/album/description')->{Contents}}) {
+- if (UNIVERSAL::isa($element, 'XML::Grove::Element') && $element->{Name} eq "field") {
+- $fieldName = $element->{Attributes}{'name'};
+- $fieldValue = "";
+- if (grep (/^$fieldName$/, @AlbumFieldNames)) {
+- beVerbose(" Reading field '$fieldName':", 3);
+- foreach my $characters (@{$element->{Contents}}) {
+- $fieldValue .= $characters->as_canon_xml();
+- }
+- #if ($fieldName ne "shortdesc" && $fieldName ne "longdesc"){
+- # $fieldValue = decode_entities($fieldValue);
+- #}
+- if ($fieldName eq "sampleimage"){
+- $fieldValue =
+- trimWhiteSpace(decode_entities($fieldValue));
+- beVerbose("'".$fieldValue."'\n", 3);
+- }else{
+- $fieldValue =
+- trimWhiteSpace(decode_entities(xml2html($fieldValue)));
+- beVerbose("'".$fieldValue."'\n", 3);
++ if ($document->at_path("/album/description")) {
++ foreach my $element
++ (@{$document->at_path('/album/description')->{Contents}}) {
++ if (UNIVERSAL::isa($element, 'XML::Grove::Element') && $element->{Name} eq "field") {
++ $fieldName = $element->{Attributes}{'name'};
++ $fieldValue = "";
++ if (grep (/^$fieldName$/, @AlbumFieldNames)) {
++ beVerbose(" Reading field '$fieldName':", 3);
++ foreach my $characters (@{$element->{Contents}}) {
++ $fieldValue .= $characters->as_canon_xml();
++ }
++ #if ($fieldName ne "shortdesc" && $fieldName ne "longdesc"){
++ # $fieldValue = decode_entities($fieldValue);
++ #}
++ if ($fieldName eq "sampleimage"){
++ $fieldValue =
++ trimWhiteSpace(decode_entities($fieldValue));
++ beVerbose("'".$fieldValue."'\n", 3);
++ }else{
++ $fieldValue =
++ trimWhiteSpace(decode_entities(xml2html($fieldValue)));
++ beVerbose("'".$fieldValue."'\n", 3);
++ }
++ # $fieldValue = $encode->(trimWhiteSpace($fieldValue));
++ $hash->{$fieldName} = $fieldValue;
++ } else {
++ beVerboseN(" Ignoring unknown field '$fieldName'.", 3);
+ }
+- # $fieldValue = $encode->(trimWhiteSpace($fieldValue));
+- $hash->{$fieldName} = $fieldValue;
+- } else {
+- beVerboseN(" Ignoring unknown field '$fieldName'.", 3);
+ }
+ }
+- }
++ }
+ return $configHash;
+ }
+
+
Property changes on: trunk/patches/12_optional_xml_elements.dpatch
___________________________________________________________________
Name: svn:executable
+ *
More information about the pkg-bins-commits
mailing list