[CssSelector] added css selector with empty string

This commit is contained in:
Simon Constans 2012-12-11 19:25:03 +01:00 committed by Fabien Potencier
parent fc7a39ccd4
commit dbafc2c365
2 changed files with 2 additions and 1 deletions

View File

@ -129,7 +129,7 @@ class Tokenizer
}
$result = substr($s, $start, $next - $start);
if ('\\' === $result[strlen($result) - 1]) {
if (strlen($result) > 0 && '\\' === $result[strlen($result) - 1]) {
// next quote character is escaped
$pos = $next + 1;
continue;

View File

@ -34,6 +34,7 @@ class TokenizerTest extends \PHPUnit_Framework_TestCase
{
$this->assertEquals('foo[class=foo bar ]', $this->tokensToString($this->tokenizer->tokenize('foo[class="foo bar"]')), '->tokenize() lexes an input string and returns an array of tokens');
$this->assertEquals("foo[class=foo Abar ]", $this->tokensToString($this->tokenizer->tokenize('foo[class="foo \\65 bar"]')), '->tokenize() lexes an input string and returns an array of tokens');
$this->assertEquals("img[alt= ]", $this->tokensToString($this->tokenizer->tokenize('img[alt=""]')), '->tokenize() lexes an input string and returns an array of tokens');
}
/**