8000 [Yaml] Throw exception for tagged invalid inline elements · symfony/symfony@bed479c · GitHub
[go: up one dir, main page]

Skip to content

Commit bed479c

Browse files
committed
[Yaml] Throw exception for tagged invalid inline elements
1 parent e7f7041 commit bed479c

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/Symfony/Component/Yaml/Inline.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,15 @@ public static function parse($value, $flags = 0, $references = [])
126126
$result = self::parseScalar($value, $flags, null, $i, null === $tag, $references);
127127
}
128128

129-
if (null !== $tag) {
130-
return new TaggedValue($tag, $result);
131-
}
132-
133129
// some comments are allowed at the end
134130
if (preg_replace('/\s+#.*$/A', '', substr($value, $i))) {
135131
throw new ParseException(sprintf('Unexpected characters near "%s".', substr($value, $i)), self::$parsedLineNumber + 1, $value, self::$parsedFilename);
136132
}
137133

134+
if (null !== $tag) {
135+
return new TaggedValue($tag, $result);
136+
}
137+
138138
return $result;
139139
} finally {
140140
if (isset($mbEncoding)) {

src/Symfony/Component/Yaml/Tests/InlineTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,12 @@ public function testParseInvalidSequenceShouldThrowException()
201201
Inline::parse('{ foo: bar } bar');
202202
}
203203

204+
public function testParseInvalidTaggedSequenceShouldThrowException()
205+
{
206+
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
207+
Inline::parse('!foo { bar: baz } qux', Yaml::PARSE_CUSTOM_TAGS);
208+
}
209+
204210
public function testParseScalarWithCorrectlyQuotedStringShouldReturnString()
205211
{
206212
$value = "'don''t do somthin'' like that'";

0 commit comments

Comments
 (0)
0