Author: Derick Rethans
Date: 2006-01-23 13:29:58 +0100 (Mon, 23 Jan 2006)
New Revision: 2004

Log:
- Added HTML escaping of exception messages so that they show up correctly in
  a browser. The original message is stored in the originalMessage property
  in the exception object.

Modified:
   packages/Base/trunk/ChangeLog
   packages/Base/trunk/src/exceptions/exception.php
   packages/Base/trunk/tests/base_test.php

Modified: packages/Base/trunk/ChangeLog
===================================================================
--- packages/Base/trunk/ChangeLog       2006-01-23 10:59:56 UTC (rev 2003)
+++ packages/Base/trunk/ChangeLog       2006-01-23 12:29:58 UTC (rev 2004)
@@ -1,3 +1,11 @@
+1.0 - [RELEASEDATE]
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+- Added HTML escaping of exception messages so that they show up correctly in 
+  a browser. The original message is stored in the originalMessage property
+  in the exception object.
+
+
 1.0rc1 - Monday 16 January 2006
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 

Modified: packages/Base/trunk/src/exceptions/exception.php
===================================================================
--- packages/Base/trunk/src/exceptions/exception.php    2006-01-23 10:59:56 UTC 
(rev 2003)
+++ packages/Base/trunk/src/exceptions/exception.php    2006-01-23 12:29:58 UTC 
(rev 2004)
@@ -16,5 +16,28 @@
  */
 abstract class ezcBaseException extends Exception
 {
+    /**
+     * Original message, before escaping
+     */
+    public $originalMessage;
+
+    /**
+     * Constructs a new ezcBaseException with $message
+     *
+     * @param string $message
+     */
+    public function __construct( $message )
+    {
+        $this->originalMessage = $message;
+
+        if ( php_sapi_name() == 'cli' )
+        {
+            parent::__construct( $message );
+        }
+        else
+        {
+            parent::__construct( htmlspecialchars( $message ) );
+        }
+    }
 }
 ?>

Modified: packages/Base/trunk/tests/base_test.php
===================================================================
--- packages/Base/trunk/tests/base_test.php     2006-01-23 10:59:56 UTC (rev 
2003)
+++ packages/Base/trunk/tests/base_test.php     2006-01-23 12:29:58 UTC (rev 
2004)
@@ -237,6 +237,7 @@
         catch ( ezcBaseValueException $e )
         {
             $this->assertEquals( "The value <string> that you were trying to 
assign to setting <broken> is invalid. Allowed values are: strings.", 
$e->getMessage() );
+            $this->assertEquals( "The value <string> that you were trying to 
assign to setting <broken> is invalid. Allowed values are: strings.", 
$e->originalMessage );
         }
     }
 

-- 
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components

Reply via email to