Code

Updated PPD parsing
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 30 Apr 2010 11:21:31 +0000 (11:21 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 30 Apr 2010 11:21:31 +0000 (11:21 +0000)
-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

gosa-plugins/goto/admin/systems/ppd/class_ppdManager.inc

index 76012c045dff2083437bbc1f49c3548534ead563..bae18536a97e46a1db319b41b05eec50452d40c4 100644 (file)
@@ -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: "<</HWResolution [300 300] >> setpagedevice"
+                    // and
+                    //  *Resolution 300dpi/300: "<</HWResolution [300 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);
        }