Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 52f8fc8

Browse filesBrowse files
committed
bug #33818 [Yaml] Throw exception for tagged invalid inline elements (gharlan)
This PR was merged into the 3.4 branch. Discussion ---------- [Yaml] Throw exception for tagged invalid inline elements | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | n/a | License | MIT | Doc PR | n/a At the moment the result for `!foo 'don't do somthin' like that'` is a `TaggedValue` with value "don". Commits ------- bed479c [Yaml] Throw exception for tagged invalid inline elements
2 parents 29cabf9 + bed479c commit 52f8fc8
Copy full SHA for 52f8fc8

File tree

2 files changed

+10
-4
lines changed
Filter options

2 files changed

+10
-4
lines changed

‎src/Symfony/Component/Yaml/Inline.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Yaml/Inline.php
+4-4Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Yaml/Tests/InlineTest.php
+6Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.