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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: parf at comfi dot com
New email:
PHP Version: OS:

 

 [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-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 20:01:28 2024 UTC