Special Ops 2.50
[specialops2.git] / lib / Post_XML.php
blob725980d75e6102f8b9d65863473434a19a29c7ea
1 <?php
2 /**
3 * XML message parser - doesn't do anything other than an XML well-formedness check
5 * @author Ant P <p@cpi.merseine.nu>
6 * @license file://../COPYING
7 * @version 2.15
8 */
9 require_once 'lib/iface.Message3.php';
11 class Post_XML implements Message3
13 private $output = null;
15 function __construct($input, $formatting = null)
17 if ( strpos($input, '<script') !== false || strpos($input, '-moz-binding') !== false ) {
18 throw new Exception('Your post contains something that looks like HTML scripting.');
21 // No nl2br here, anyone using this should know what they're doing
22 $this->output = str_replace("\r\n", "\n", $input);
25 function validate()
27 // Check for malformed XML, doesn't really do much else
28 $parser = xml_parser_create('UTF-8');
30 if ( !xml_parse($parser, '<div>'.$this->output.'</div>', true) ) {
31 throw new InvalidInputException(xml_error_string(xml_get_error_code($parser)), xml_get_current_line_number($parser));
35 function getOutput()
37 return $this->output;