Skip to content
This repository has been archived by the owner on Jan 31, 2019. It is now read-only.

Commit

Permalink
Fixed bug in StripTags Filter where "&" was converted to ">" instead …
Browse files Browse the repository at this point in the history
…of leaving it like it was. Also added "Filter" group to every unit test that has something to do with the filters.
  • Loading branch information
Ephigenia committed Oct 12, 2012
1 parent a2abe07 commit 790b5de
Show file tree
Hide file tree
Showing 15 changed files with 47 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/ephFrame/Filter/StripTags.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ public function apply($value)
{
// first replace various encodings of < and > back to < and >
$r = array(
'@%3C|&gt;?|&#0*60;?|&#x0*3C;?|\\\x3C|\\\u003C@' => '<',
'@&(?!(amp;|#\d{2,}))@i' => '>',
'@%3E|&lt;?|&#0*62;?|&#x0*3E;?|\\\x3E|\\\u003E@' => '&amp;',
'@%3C|&gt;?|&#0\*60;?|&#x0\*3C;?|\\\x3C|\\\u003C@i' => '<',
'@%3E|&lt;?|&#0\*62;?|&#x0\*3E;?|\\\x3E|\\\u003E@i' => '>',
'@&(?!(amp;|#\d{2,}))@i' => '&',
);
$value = preg_replace(array_keys($r), array_values($r), $value);
// then strip not allowed tags
Expand Down
3 changes: 3 additions & 0 deletions lib/ephFrame/test/Filter/AlphaNumericTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

use ephFrame\Filter\AlphaNumeric;

/**
* @group Filter
*/
class AlphaNumericTest extends \PHPUnit_Framework_TestCase
{
public function setUp()
Expand Down
3 changes: 3 additions & 0 deletions lib/ephFrame/test/Filter/AlphaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

use ephFrame\Filter\Alpha;

/**
* @group Filter
*/
class AlphaTest extends \PHPUnit_Framework_TestCase
{
public function setUp()
Expand Down
3 changes: 3 additions & 0 deletions lib/ephFrame/test/Filter/BasenameTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

use ephFrame\Filter\Basename;

/**
* @group Filter
*/
class BasenameTest extends \PHPUnit_Framework_TestCase
{
public function setUp()
Expand Down
3 changes: 3 additions & 0 deletions lib/ephFrame/test/Filter/BooleanTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

use ephFrame\Filter\Boolean;

/**
* @group Filter
*/
class BooleanTest extends \PHPUnit_Framework_TestCase
{
public function setUp()
Expand Down
3 changes: 3 additions & 0 deletions lib/ephFrame/test/Filter/FloatTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

use \ephFrame\Filter\Float;

/**
* @group Filter
*/
class FloatTest extends \PHPUnit_Framework_TestCase
{
public function setUp()
Expand Down
3 changes: 3 additions & 0 deletions lib/ephFrame/test/Filter/HTMLEntitiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

use \ephFrame\Filter\HTMLEntities;

/**
* @group Filter
*/
class HTMLEntitiesTest extends \PHPUnit_Framework_TestCase
{
public function setUp()
Expand Down
3 changes: 3 additions & 0 deletions lib/ephFrame/test/Filter/IntegerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

use \ephFrame\Filter\Integer;

/**
* @group Filter
*/
class IntegerTest extends \PHPUnit_Framework_TestCase
{
public function setUp()
Expand Down
3 changes: 3 additions & 0 deletions lib/ephFrame/test/Filter/NormalizeLineBrakesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

use ephFrame\Filter\NormalizeLineBrakes;

/**
* @group Filter
*/
class NormalizeLineBrakesTest extends \PHPUnit_Framework_TestCase
{
public function setUp()
Expand Down
3 changes: 3 additions & 0 deletions lib/ephFrame/test/Filter/NumberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

use \ephFrame\Filter\Number;

/**
* @group Filter
*/
class NumberTest extends \PHPUnit_Framework_TestCase
{
public function setUp()
Expand Down
3 changes: 3 additions & 0 deletions lib/ephFrame/test/Filter/PregReplaceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

use \ephFrame\Filter\PregReplace;

/**
* @group Filter
*/
class PregReplaceTest extends \PHPUnit_Framework_TestCase
{
public function setUp()
Expand Down
3 changes: 3 additions & 0 deletions lib/ephFrame/test/Filter/StripNewlinesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

use ephFrame\Filter\StripNewlines;

/**
* @group Filter
*/
class StripNewlinesTest extends \PHPUnit_Framework_TestCase
{
public function setUp()
Expand Down
6 changes: 5 additions & 1 deletion lib/ephFrame/test/Filter/StripTagsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

use ephFrame\Filter\StripTags;

/**
* @group Filter
*/
class StripTagsTest extends \PHPUnit_Framework_TestCase
{
public function setUp()
Expand All @@ -21,6 +24,7 @@ public function testSimpleValues()
array('<em>highlight</em>', 'highlight'),
array('<em class="test me">highlight</em>', 'highlight'),
array('<<em class="test me">double</em>', ''),
array('Oiltanking & Something else', 'Oiltanking & Something else'),
// array('<no entity at all', 'no html entity at all'), // @todo make this work!
);
}
Expand All @@ -40,7 +44,7 @@ public function testXSSValues()
array('<SCRIPT>alert("XSS");//</SCRIPT>', 'alert("XSS");//'),
array('<BODY BACKGROUND="javascript:alert(\'XSS\')">', ''),
array('<BODY BACKGROUND="javascript:alert(\'XSS\')" />', ''),
array('%3Cbold&#0*62;?test', '#0*62;?test'),
array('%3Cbold&#0*62;test', 'test'),
array('</TITLE><SCRIPT>alert("XSS");</SCRIPT>', 'alert("XSS");'),
array('<SCRIPT =">" SRC="http://ha.ckers.org/xss.js"></SCRIPT>', ''),
);
Expand Down
3 changes: 3 additions & 0 deletions lib/ephFrame/test/Filter/StripWhiteSpaceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

use ephFrame\Filter\StripWhiteSpace;

/**
* @group Filter
*/
class StripWhiteSpaceTest extends \PHPUnit_Framework_TestCase
{
public function setUp()
Expand Down
3 changes: 3 additions & 0 deletions lib/ephFrame/test/Filter/TrimTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

use ephFrame\Filter\Trim;

/**
* @group Filter
*/
class TrimTest extends \PHPUnit_Framework_TestCase
{
public function setUp()
Expand Down

0 comments on commit 790b5de

Please sign in to comment.