* Minor TOS change
[specialops2.git] / lib / class.Message_XML.php
blob26f0fbd5256c689615932655159af882e2d1e2cb
1 <?php
2 /**
3 * Doesn't do anything other than an XML well-formedness check
5 * @author Ant P. <xmpp:ant@specialops.ath.cx>
6 * @version 2.3
7 * @license http://specialops.ath.cx/repos/so2/trunk/COPYING
8 */
9 require_once 'lib/iface.Message3.php';
11 class Message_XML implements Message3
13 private $output = null;
15 function __construct($input, $formatting = null)
17 if ( strpos($input, '<script') !== false ) {
18 throw new Exception('No.');
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;