Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions classes/parsers/plist/PlistParser.inc
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ class plistParser extends XMLReader
'plistParser::parse() is deprecated, please use plistParser::parseFile()',
E_USER_NOTICE
);

return $this->parseFile($file);
}

public function parseFile($file) {
if(basename($file) == $file) {
throw new Exception("Non-relative file path expected", 1);
}
$this->open("file://" . $file);
$fileData = file_get_contents("file://" .$file);
//replaces non self closing empty array elements with self closing elements
$fileData = preg_replace('/<array>\s+<\/array>/ism','<array />',$fileData);
$this->xml($fileData);
return $this->process();
}

Expand Down Expand Up @@ -79,7 +81,15 @@ class plistParser extends XMLReader
return false;
break;
case 'array':
return $this->parse_array();
//tests for empty arrays and gracefully moves on keeping the structure of the document intact.
$tmpAarrayTest = $this->readInnerXML();
$tmpAarrayTest = trim($tmpAarrayTest);
if (empty($tmpAarrayTest)) {
return array();
} else {
return $this->parse_array();
}
$tmpAarrayTest = null;
break;
case 'dict':
return $this->parse_dict();
Expand Down