php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75432 incorrect yaml parsing
Submitted: 2017-10-24 19:27 UTC Modified: 2018-11-12 22:18 UTC
From: parf at comfi dot com Assigned:
Status: Not a bug Package: yaml (PECL)
PHP Version: 7.1.10 OS: linux
Private report: No CVE-ID: None
 [2017-10-24 19:27 UTC] parf at comfi dot com
Description:
------------
---
From manual page: http://www.php.net/function.yaml-parse
---
yaml_parse and yaml_parse_file incorretly parses yaml


Test script:
---------------
> yaml_parse('N: 1')
Array(
  [] => 1
)
> yaml_parse('n: 1')
Array(
  [] => 1
)
> yaml_parse('a: 1')
Array(
  a => 1
)
> yaml_parse('l: 1')
Array(
  l => 1
)
> yaml_parse('NN: 1')
Array(
  NN => 1
)


Expected result:
----------------
> yaml_parse('N: 1')
Array(
  'N' => 1
)
> yaml_parse('n: 1')
Array(
  'n' => 1
)

Actual result:
--------------
> yaml_parse('N: 1')
Array(
  [] => 1
)
> yaml_parse('n: 1')
Array(
  [] => 1
)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-11-12 21:46 UTC] bd808@php.net
-Status: Open +Status: Not a bug
 [2018-11-12 21:46 UTC] bd808@php.net
The unquoted strings "N" and "n" are considered to be false boolean values per http://yaml.org/type/bool.html. You can verify this using a parse callback (https://secure.php.net/manual/en/yaml.callbacks.parse.php) for the YAML_BOOL_TAG ("tag:yaml.org,2002:bool") tag.
 [2018-11-12 22:18 UTC] parf at comfi dot com
"N" means NO only as a "value", in this case this is a "key-name"
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sat Jul 04 22:01:03 2020 UTC