From: cajus Date: Wed, 22 Jul 2009 10:58:13 +0000 (+0000) Subject: Just skip empty files X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=fac2448dcde20d5306763f0a49104a4a6fb6507b;p=gosa.git Just skip empty files git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13942 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 b151dc579..76012c045 100644 --- a/gosa-plugins/goto/admin/systems/ppd/class_ppdManager.inc +++ b/gosa-plugins/goto/admin/systems/ppd/class_ppdManager.inc @@ -191,13 +191,19 @@ class ppdManager $option= ""; $properties= array(); - $fh= gzopen ($ppdFile, 'r'); + // Check for empty files + if(!filesize($ppdFile)) { + trigger_error(_('Parsing PPD file failed - file is empty!')); + return; + } + + $fh= gzopen ($ppdFile, 'r'); while (!gzeof($fh) && $fh){ /* Read line */ - $line= gzgets($fh, 256); + $line= gzgets($fh, 256); if (strlen($line) >= 256){ - trigger_error(_('Parsing PPD file %s failed - line too long. Trailing characters have been ignored'), E_USER_WARNING); + trigger_error(_('Parsing PPD file %s failed - line too long. Trailing characters have been ignored!'), E_USER_WARNING); } /* Trigger for option groups */ @@ -297,7 +303,7 @@ class ppdManager /* Possible value? */ if (preg_match("@^\*$eoption\s+@", $line)){ -#*PageSize Letter/US Letter: "<>setpagedevice" + #*PageSize Letter/US Letter: "<>setpagedevice" $c= preg_replace("@^\*$eoption\s+([^/]+).*$@", "$1", $line); $d= preg_replace("@^\*$eoption\s+[^/]+/([^:]+).*$@", "$1", $line); if(empty($group)){ @@ -315,8 +321,13 @@ class ppdManager function loadDescription($ppdFile) { - - $ppdDesc = array(); + // Check for empty files + if(!filesize($ppdFile)) { + trigger_error(_('Parsing PPD file failed - file is empty!')); + return; + } + + $ppdDesc = array(); /* Only parse complete PPD file again, if it was changed */ $modified = filemtime($ppdFile);