Skip to content

Commit 345be29

Browse files
Merge pull request sebastianbergmann#832 from whatthejeff/issue_830
2 parents 2eb833b + b4c9849 commit 345be29

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

PHPUnit/Util/XML.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ class PHPUnit_Util_XML
6565
public static function prepareString($string)
6666
{
6767
return preg_replace_callback(
68-
'([\\x00-\\x04\\x0b\\x0c\\x0e-\\x1f\\x7f])',
68+
'/[\\x00-\\x04\\x0b\\x0c\\x0e-\\x1f\\x7f]/',
6969
function ($matches)
7070
{
71-
return sprintf('&#x%02x;', ord($matches[1]));
71+
return sprintf('&#x%02x;', ord($matches[0]));
7272
},
7373
htmlspecialchars(
7474
PHPUnit_Util_String::convertToUtf8($string), ENT_COMPAT, 'UTF-8'

Tests/Util/XMLTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,4 +320,9 @@ public function testConvertAssertRange()
320320

321321
$this->assertEquals($tag, $converted);
322322
}
323+
324+
public function testPrepareStringEscapesChars()
325+
{
326+
$this->assertEquals('', PHPUnit_Util_XML::prepareString("\033"));
327+
}
323328
}

0 commit comments

Comments
 (0)