From 33d4e502c443737aa8a66967bcc1dda74612c34e Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 30 Apr 2010 11:21:31 +0000 Subject: [PATCH] Updated PPD parsing -We've had problems parsing some special attributes. git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6@17992 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../admin/systems/ppd/class_ppdManager.inc | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/gosa-plugins/goto/admin/systems/ppd/class_ppdManager.inc b/gosa-plugins/goto/admin/systems/ppd/class_ppdManager.inc index 76012c045..bae18536a 100644 --- a/gosa-plugins/goto/admin/systems/ppd/class_ppdManager.inc +++ b/gosa-plugins/goto/admin/systems/ppd/class_ppdManager.inc @@ -303,18 +303,26 @@ class ppdManager /* Possible value? */ if (preg_match("@^\*$eoption\s+@", $line)){ - #*PageSize Letter/US Letter: "<>setpagedevice" - $c= preg_replace("@^\*$eoption\s+([^/]+).*$@", "$1", $line); - $d= preg_replace("@^\*$eoption\s+[^/]+/([^:]+).*$@", "$1", $line); + + // Detect what comes first, the '/' or the ':'. + // We may have entries like this: + // *Resolution 300dpi: "<> setpagedevice" + // and + // *Resolution 300dpi/300: "<> setpagedevice" + $name = $value = preg_replace("@^\*$eoption\s+([^:]+).*$@", "$1", $line); + if(preg_match("/\//", $name)){ + list($name, $value) = preg_split("/\//", $name); + } if(empty($group)){ - $properties["NO_SECTION"][$option][trim($c)]= trim($d); + $properties["NO_SECTION"][$option][$name]= $value; }else{ - $properties[$group][$option][trim($c)]= trim($d); + $properties[$group][$option][$name]= $value; } continue; } } } + gzclose ($fh); return ($properties); } -- 2.30.2