Skip to content

[Yaml] Incorrect parsing of objects with inline comments #59785

Closed
@andrey-tech

Description

@andrey-tech

Symfony version(s) affected

6.4.18

Description

The Yaml Component (6.4.18) has an issue parsing objects with inline comments.

ℹ️ This issue is not present in version 6.4.13.

How to reproduce

use Symfony\Component\Yaml\Yaml;

$yml = <<<'YML'
arguments:
  - {
      connect_timeout: 3, # Float describing the number of seconds to wait while trying to connect to a server
      timeout: 30 # Float describing the timeout of the request in seconds
  }
YML;

var_dump(Yaml::parse($yml));

Output:

array(1) {
  ["arguments"]=>
  array(1) {
    [0]=>
    array(2) {
      ["connect_timeout"]=>
      int(3)
      ["timeout"]=>
      string(59) "30 # Float describing the timeout of the request in seconds"
    }
  }
}

Expected: integer value 30 in second element of array:

[
    "arguments" => [
        [
            "connect_timeout" => 3,
            "timeout" => 30
        ]
     ]
]

Actual: string value 30 # Float describing the timeout of the request in seconds in second element of array:

[
    "arguments" => [
        [
            "connect_timeout" => 3,
            "timeout" => "30 # Float describing the timeout of the request in seconds"
        ]
     ]
]

Possible Solution

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy