$dbr = wfGetDB(DB_SLAVE);
try {
libxml_use_internal_errors(true); // without that, we get PHP Warnings if the $input is not well-formed
- $xml = new SimpleXMLElement('<rodelbahntabelle>' . $input . '</rodelbahntabelle>'); // input
+ try {
+ $xml_input = '<rodelbahntabelle>' . $input . '</rodelbahntabelle>';
+ $xml = new SimpleXMLElement($xml_input); // input
+ } catch (Exception $e) {
+ throw new WrReportException(wfMessage('wrreport-rodelbahntabelle-invalid-xml', $xml_input)->text());
+ }
$whitespace = (string) $xml; // everything between <rodelbahntabelle> and </rodelbahntabelle> that's not a sub-element
if (strlen($whitespace) > 0 && !ctype_space($whitespace)) // there must not be anythin except sub-elements or whitespace
throw new WrReportException(wfMessage('wrreport-rodelbahntabelle-textbetweenelements', trim($xml))->text());
'wrreport-bahnenregiontabelle-error' => 'Text. Text describing that an error in paring/using the <bahnenregiontabelle> tag occurred. $1 gives details.',
'wrreport-rodelbahntabelle-error' => 'Text. Text describing that an error in paring/using the <rodelbahntabelle> tag occurred. $1 gives details.',
'wrreport-rodelbahntabelle-textbetweenelements' => 'Text. Error message describing that invalid text is found between elements. $1 gives the complete XML.',
+ 'wrreport-rodelbahntabelle-invalid-xml' => 'Text. Error message describing that the XML could not be parsed. $1 gives the complete invalid XML.',
'wrreport-rodelbahntabelle-invalid-element' => 'Text. Error message describing that the element given as $1 is not known.',
'wrreport-rodelbahntabelle-invalid-attribute-name' => 'Text. Error message describing that the attribute given as $2 of the elment given as $1 is not known.',
'wrreport-rodelbahntabelle-invalid-attribute-value' => 'Text. Error message describing that the value $3 of the attribut given as $2 of the element given as $1 is not known.',
'wrreport-bahnenregiontabelle-invalidargument' => 'The argument $1 is not allowed.',
'wrreport-bahnenregiontabelle-error' => 'The following error occurred at the <bahnenregiontabelle> tag: $1',
'wrreport-rodelbahntabelle-error' => 'The following error occurred while parsing <rodelbahntabelle>: $1',
+ 'wrreport-rodelbahntabelle-invalid-xml' => 'XML could not be parsed: $1',
'wrreport-rodelbahntabelle-textbetweenelements' => 'Unknown text was found between the subelements: $1',
'wrreport-rodelbahntabelle-invalid-element' => 'The element $1 is not known.',
'wrreport-rodelbahntabelle-invalid-attribute-name' => 'The attribute $2 of element $1 is not known.',