--- bugreport.class.php-orig	2007-12-27 12:45:18.000000000 +1100
+++ bugreport.class.php	2007-12-27 13:51:12.000000000 +1100
@@ -44,40 +44,60 @@
     }
 
     function load_report($report,$isfile=false) {
-      $xml=new XML();
-      if($isfile) {
-	$xml->load_file($report);
-      } else {
-	$xml->load_text($report);
-      }
+    
+		if ($isfile)
+			$report = file_get_contents($report);
+			
+		/*	Temporary fix for a bug in aMSN's error reporting - It does not
+			properly escape the stack trace. So, we kinda fix that here, by
+			using a regular expression to replace <whatever> with
+			&lt;whatever&gt;, inside the stack trace. Ugly hack, should be fixed
+			in aMSN.
+		*/
+		if ($report_fixed = preg_replace('/<stack>([^<]+?)<([^>]+?)>([^>]+?)<\/stack>/', '<stack>$1&lt;$2&gt;$3</stack>', $report))
+			$report = $report_fixed;
+			
+		// Turn off error reporting for now.
+		error_reporting(0);
+	   	
+		try {
+			$xml = new SimpleXMLElement($report);
+		} catch (Exception $e) {
+			// Should probably do some error logging here.
+			//$stack = $e->getTrace();
+			die('Sorry, an error occurred whilst submitting your bug report.');
+		}
+	
+		// Turn error reporting back on.
+		error_reporting(E_ALL);
 
-      $this->_version=$xml->get_content('/bug[1]/attribute::version');
-      //set error stuff
-      $this->date=html_entity_decode($xml->get_content('/bug[1]/error[1]/date[1]'));
-      $this->text=html_entity_decode($xml->get_content('/bug[1]/error[1]/text[1]'));
-      $this->stack=html_entity_decode($xml->get_content('/bug[1]/error[1]/stack[1]'));
-      $this->code=html_entity_decode($xml->get_content('/bug[1]/error[1]/code[1]'));
-      //set system stuff
-      $this->amsn=html_entity_decode($xml->get_content('/bug[1]/system[1]/amsn[1]'));
-      $this->revision=html_entity_decode($xml->get_content('/bug[1]/system[1]/revision[1]'));
-      $this->cvs_date=html_entity_decode($xml->get_content('/bug[1]/system[1]/date[1]'));
-      $this->tcl=html_entity_decode($xml->get_content('/bug[1]/system[1]/tcl[1]'));
-      $this->tk=html_entity_decode($xml->get_content('/bug[1]/system[1]/tk[1]'));
-      $this->osversion=html_entity_decode($xml->get_content('/bug[1]/system[1]/osversion[1]'));
-      $this->byteorder=html_entity_decode($xml->get_content('/bug[1]/system[1]/byteorder[1]'));
-      $this->threaded=html_entity_decode($xml->get_content('/bug[1]/system[1]/threaded[1]'));
-      $this->machine=html_entity_decode($xml->get_content('/bug[1]/system[1]/machine[1]'));
-      $this->platform=html_entity_decode($xml->get_content('/bug[1]/system[1]/platform[1]'));
-      $this->os=html_entity_decode($xml->get_content('/bug[1]/system[1]/os[1]'));
-      $this->user=html_entity_decode($xml->get_content('/bug[1]/system[1]/user[1]'));
-      $this->wordsize=html_entity_decode($xml->get_content('/bug[1]/system[1]/wordsize[1]'));
-      $this->msnprotocol=html_entity_decode($xml->get_content('/bug[1]/system[1]/msnprotocol[1]'));
-      //set extra stuff
-      $this->status_log=html_entity_decode($xml->get_content('/bug[1]/extra[1]/status_log[1]'));
-      $this->protocol_log=html_entity_decode($xml->get_content('/bug[1]/extra[1]/protocol_log[1]'));
-      //set user info
-      $this->email=html_entity_decode($xml->get_content('/bug[1]/user[1]/email[1]'));
-      $this->comment=trim(html_entity_decode($xml->get_content('/bug[1]/user[1]/comment[1]')));
+		$this->_version = $xml['version'];
+		// Error stuff.
+		$this->date = $xml->error->date;
+		$this->text = $xml->error->text;
+		$this->stack = $xml->error->stack;
+		$this->code = $xml->error->code;
+		// System stuff.
+		$this->amsn = $xml->system->amsn;
+		$this->revision = $xml->system->revision;
+		$this->cvs_date = $xml->system->date;
+		$this->tcl = $xml->system->tcl;
+		$this->tk = $xml->system->tk;
+		$this->osversion = $xml->system->osversion;
+		$this->byteorder = $xml->system->byteorder;
+		$this->threaded = $xml->system->threaded;
+		$this->machine = $xml->system->machine;
+		$this->platform = $xml->system->platform;
+		$this->os = $xml->system->os;
+		$this->user = $xml->system->user;
+		$this->wordsize = $xml->system->wordsize;
+		$this->msnprotocol = $xml->system->msnprotocol;
+		// Extra stuff.
+		$this->status_log = $xml->extra->status_log;
+		$this->protocol_log = $xml->extra->protocol_log;
+		// User info.
+		$this->email = $xml->user->email;
+		$this->comment = trim($xml->user->comment);
     }
     
 #checks if this is a valid report
