Skip to content

Fixes #830. #832

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 20, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions PHPUnit/Util/XML.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ class PHPUnit_Util_XML
public static function prepareString($string)
{
return preg_replace_callback(
'([\\x00-\\x04\\x0b\\x0c\\x0e-\\x1f\\x7f])',
'/[\\x00-\\x04\\x0b\\x0c\\x0e-\\x1f\\x7f]/',
function ($matches)
{
return sprintf('&#x%02x;', ord($matches[1]));
return sprintf('&#x%02x;', ord($matches[0]));
},
htmlspecialchars(
PHPUnit_Util_String::convertToUtf8($string), ENT_COMPAT, 'UTF-8'
Expand Down
5 changes: 5 additions & 0 deletions Tests/Util/XMLTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,4 +320,9 @@ public function testConvertAssertRange()

$this->assertEquals($tag, $converted);
}

public function testPrepareStringEscapesChars()
{
$this->assertEquals('', PHPUnit_Util_XML::prepareString("\033"));
}
}