Skip to content

Error on optional string escapes in input, even though valid in JSON #984

Open
@chaimleib

Description

@chaimleib

Describe the bug
According to the JSON spec (YAML is a superset of JSON), YAML 1.2.2, and YAML 1.3.0, "\/" is valid string syntax, equivalent to "/".

However, when "\/" exists on the input to yq, the escaped character is not recognized.

Version of yq: 4.13.3
Operating system: mac
Installed via: go install github.com/mikefarah/yq/v4@v4.13.3 under go1.17.2 darwin/amd64

Input

test.yml

["\/"]

Command
The command you ran:

yq e '.[0]' test.yml

Actual behavior

Error: yaml: found unknown escape character

Expected behavior

/

Additional context

Optional escapes on input strings work fine with jq-1.6:

% jq -r '.[0]' test.yml
/

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions