Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitec7f68e

Browse files
#20411 fix Yaml parsing for very long quoted strings
1 parent6e001c8 commitec7f68e

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function __construct($offset = 0, $totalNumberOfLines = null, array $skip
6161
*/
6262
publicfunctionparse($value,$exceptionOnInvalidType =false,$objectSupport =false,$objectForMap =false)
6363
{
64-
if (!self::preg_match('//u',$value)) {
64+
if (false ===preg_match('//u',$value)) {
6565
thrownewParseException('The YAML value does not appear to be valid UTF-8.');
6666
}
6767
$this->currentLineNb = -1;
@@ -127,7 +127,6 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport =
127127
}elseif (self::preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^\'"\[\{].*?) *\:(\s+(?P<value>.+))?$#u',rtrim($this->currentLine),$values)
128128
&& (false ===strpos($values['key'],' #')
129129
||in_array($values['key'][0],array('"',"'")))) {
130-
131130
if ($context &&'sequence' ==$context) {
132131
thrownewParseException('You cannot define a mapping item when in a sequence',$this->currentLineNb +1,$this->currentLine);
133132
}
@@ -269,7 +268,7 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport =
269268
return$value;
270269
}
271270

272-
thrownewParseException("Unable to parse",$this->getRealCurrentLineNb() +1,$this->currentLine);
271+
thrownewParseException('Unable to parse',$this->getRealCurrentLineNb() +1,$this->currentLine);
273272
}
274273
}
275274

@@ -794,9 +793,11 @@ private function isBlockScalarHeader()
794793
* in the YAML engine
795794
*
796795
* @throws ParseException on a PCRE internal error
796+
*
797797
* @see preg_last_error()
798+
* @internal
798799
*/
799-
staticfunctionpreg_match($pattern,$subject, &$matches =null,$flags =0,$offset =0)
800+
publicstaticfunctionpreg_match($pattern,$subject, &$matches =null,$flags =0,$offset =0)
800801
{
801802
$ret =preg_match($pattern,$subject,$matches,$flags,$offset);
802803
if ($ret ===false) {
@@ -822,6 +823,7 @@ static function preg_match($pattern, $subject, &$matches = null, $flags = 0, $of
822823

823824
thrownewParseException($error);
824825
}
826+
825827
return$ret;
826828
}
827829
}

‎src/Symfony/Component/Yaml/Tests/ParserTest.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,8 +1147,8 @@ public function parserThrowsExceptionWithCorrectLineNumberProvider()
11471147

11481148
publicfunctiontestCanParseVeryLongValue()
11491149
{
1150-
$longStringWithSpaces =str_repeat("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",20000);
1151-
$trickyVal =array("x" =>$longStringWithSpaces);
1150+
$longStringWithSpaces =str_repeat('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',20000);
1151+
$trickyVal =array('x' =>$longStringWithSpaces);
11521152

11531153
$yamlString = Yaml::dump($trickyVal);
11541154
$arrayFromYaml =$this->parser->parse($yamlString);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp