Skip to content

YAML 1.1 Pair, Key is y, get parsed to true (bool) #574

@sharky98

Description

@sharky98

Describe the bug
When parsing a Unity YAML file, one object is defined with key-value pairs, including one with a y in it (like in X,Y coordinates). When parsed, the key is transformed to a boolean true.

To Reproduce

Using the Playground, parse the following YAML

%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!213 &21300000
Sprite:
  m_Rect:
    x: 0
    y: 128
    width: 128
    height: 128

gives the following result:

[
  Pair {
    key: Scalar { value: 'x', range: [Array], source: 'x', type: 'PLAIN' },
    value: Scalar { value: 0, range: [Array], source: '0', type: 'PLAIN' }
  },
  Pair {
    key: Scalar { value: true, range: [Array], source: 'y', type: 'PLAIN' },
    value: Scalar { value: 128, range: [Array], source: '128', type: 'PLAIN' }
  },
  Pair {
    key: Scalar { value: 'width', range: [Array], source: 'width', type: 'PLAIN' },
    value: Scalar { value: 128, range: [Array], source: '128', type: 'PLAIN' }
  },
  Pair {
    key: Scalar { value: 'height', range: [Array], source: 'height', type: 'PLAIN' },
    value: Scalar { value: 128, range: [Array], source: '128', type: 'PLAIN' }
  }
]

Expected behaviour
The key of a key-value pair, should not be transformed according to the boolean rule.

Versions (please complete the following information):

  • Environment: Node 22.8.0
  • yaml: 2.5.1

Additional context

I found the schema used, but I have no clues where it get used when parsing the key.

https://github.com/eemeli/yaml/blob/5adbb605b64094b57bc95cbc24587e6f36b3f9a8/src/schema/yaml-1.1/bool.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions