From: <ste...@us...> - 2012-11-14 21:49:33
|
Revision: 11941 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=11941&view=rev Author: stephenjust Date: 2012-11-14 21:49:26 +0000 (Wed, 14 Nov 2012) Log Message: ----------- [stkaddons] Fix lack of error messages when the XML parser can't read an uploaded file. Modified Paths: -------------- stkaddons/trunk/include/Upload.class.php stkaddons/trunk/include/parsers/Parser.class.php stkaddons/trunk/include/parsers/addonXMLParser.class.php Modified: stkaddons/trunk/include/Upload.class.php =================================================================== --- stkaddons/trunk/include/Upload.class.php 2012-11-14 11:35:39 UTC (rev 11940) +++ stkaddons/trunk/include/Upload.class.php 2012-11-14 21:49:26 UTC (rev 11941) @@ -73,7 +73,12 @@ File::flattenDirectory($this->temp, $this->temp); Upload::removeInvalidFiles(); - Upload::parseFiles(); + try { + Upload::parseFiles(); + } + catch (ParserException $e) { + throw new UploadException("Parser Exception: ".$e->getMessage()); + } // -------------------------------------------------------------------- // FIXME: This is only a temporary measure! Modified: stkaddons/trunk/include/parsers/Parser.class.php =================================================================== --- stkaddons/trunk/include/parsers/Parser.class.php 2012-11-14 11:35:39 UTC (rev 11940) +++ stkaddons/trunk/include/parsers/Parser.class.php 2012-11-14 21:49:26 UTC (rev 11941) @@ -21,6 +21,7 @@ abstract class Parser { protected $binary_file = false; protected $file = NULL; + protected $file_name = NULL; protected $file_size = 0; protected $writeable = false; @@ -39,6 +40,7 @@ $read_flag = ($write) ? 'r+' : 'r'; if ($binary) $read_flag .= 'b'; $handle = fopen($file, $read_flag); + $this->file_name = basename($file); if (!$handle) throw new ParserException('Error opening file'); $this->file = $handle; Modified: stkaddons/trunk/include/parsers/addonXMLParser.class.php =================================================================== --- stkaddons/trunk/include/parsers/addonXMLParser.class.php 2012-11-14 11:35:39 UTC (rev 11940) +++ stkaddons/trunk/include/parsers/addonXMLParser.class.php 2012-11-14 21:49:26 UTC (rev 11941) @@ -35,13 +35,13 @@ $this->file_contents = fread($this->file,$this->file_size); // Fix common XML errors $this->file_contents = trim($this->file_contents); - $this->file_contents = str_replace('& ','&',$this->file_contents); + $this->file_contents = str_replace('& ','& ',$this->file_contents); // Get type of xml file $reader = xml_parser_create(); if (!xml_parse_into_struct($reader, $this->file_contents,$values,$index)) - throw new XMLParserException('XML Error: '.xml_error_string(xml_get_error_code($reader))); + throw new XMLParserException('XML Error: '.xml_error_string(xml_get_error_code($reader)).' - file: '.$this->file_name); $this->file_type = $values[0]['tag']; $this->values = $values; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |