From: hickert Date: Fri, 30 Apr 2010 11:21:31 +0000 (+0000) Subject: Updated PPD parsing X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=33d4e502c443737aa8a66967bcc1dda74612c34e;p=gosa.git 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 --- 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); }