fix parsing comments not prefixed by a space

This commit is contained in:
Christian Flothmann 2020-09-18 10:50:51 +02:00
parent 6b8857c974
commit 35b223aaa4
2 changed files with 11 additions and 1 deletions

View File

@ -127,7 +127,7 @@ class Inline
}
// some comments are allowed at the end
if (preg_replace('/\s+#.*$/A', '', substr($value, $i))) {
if (preg_replace('/\s*#.*$/A', '', substr($value, $i))) {
throw new ParseException(sprintf('Unexpected characters near "%s".', substr($value, $i)), self::$parsedLineNumber + 1, $value, self::$parsedFilename);
}

View File

@ -860,4 +860,14 @@ class InlineTest extends TestCase
{
self::assertSame('-0123456789', Inline::parse('-0123456789'));
}
public function testParseCommentNotPrefixedBySpaces()
{
self::assertSame('foo', Inline::parse('"foo"#comment'));
}
public function testParseUnquotedStringContainingHashTagNotPrefixedBySpace()
{
self::assertSame('foo#nocomment', Inline::parse('foo#nocomment'));
}
}