[limb-svn] r6038 - in 3.x/trunk/limb/wact: src tests/cases
svn at limb-project.com
svn at limb-project.com
Mon Jul 2 10:34:26 MSD 2007
Author: serega
Date: 2007-07-02 10:34:26 +0400 (Mon, 02 Jul 2007)
New Revision: 6038
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6038
Added:
3.x/trunk/limb/wact/tests/cases/WactTemplateTest.class.php
Modified:
3.x/trunk/limb/wact/src/WactTemplate.class.php
Log:
-- WactTemplate :: escape() static method added. But it's not used anywhere in WACT yet.
Modified: 3.x/trunk/limb/wact/src/WactTemplate.class.php
===================================================================
--- 3.x/trunk/limb/wact/src/WactTemplate.class.php 2007-07-02 06:32:28 UTC (rev 6037)
+++ 3.x/trunk/limb/wact/src/WactTemplate.class.php 2007-07-02 06:34:26 UTC (rev 6038)
@@ -129,7 +129,7 @@
return $this->locator->locateSourceTemplate($this->template_path);
}
- function toStudlyCaps($str)
+ static function toStudlyCaps($str)
{
return preg_replace('~([a-zA-Z])?_([a-zA-Z])~e', "'\\1'.strtoupper('\\2')", $str);
}
@@ -143,6 +143,14 @@
fclose($fh);
return true;
}
+
+ static function escape($string)
+ {
+ $string = htmlspecialchars($string, ENT_QUOTES);
+ if(strpos($string, '&#') !== FALSE)
+ $string = preg_replace('/&#([^;]*);/', '&#$1;', $string);
+ return $string;
+ }
}
Added: 3.x/trunk/limb/wact/tests/cases/WactTemplateTest.class.php
===================================================================
--- 3.x/trunk/limb/wact/tests/cases/WactTemplateTest.class.php (rev 0)
+++ 3.x/trunk/limb/wact/tests/cases/WactTemplateTest.class.php 2007-07-02 06:34:26 UTC (rev 6038)
@@ -0,0 +1,33 @@
+<?php
+/**
+ * Limb Web Application Framework
+ *
+ * @link http://limb-project.com
+ *
+ * @copyright Copyright © 2004-2007 BIT
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ * @version $Id$
+ * @package wact
+ */
+
+require_once('limb/wact/src/WactTemplate.class.php');
+
+class WactTemplateTest extends UnitTestCase
+{
+ function testEscapeCommonCase()
+ {
+ $this->assertEqual(WactTemplate :: escape('\'A\' & "B"'), ''A' & "B"');
+ }
+
+ function testEscapeAlreadyTranslatedEntity()
+ {
+ $this->assertEqual(WactTemplate :: escape('€'), '€');
+ }
+
+ function testEscapeAlreadyTranslatedEntityWithNonNumericIndex()
+ {
+ $this->assertEqual(WactTemplate :: escape('ሴ'), 'ሴ');
+ }
+}
+
+?>
\ No newline at end of file
More information about the limb-svn
mailing list