Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escaped Backslashes gets unescaped #629

Closed
YasserGersy opened this issue Aug 12, 2021 · 1 comment
Closed

Escaped Backslashes gets unescaped #629

YasserGersy opened this issue Aug 12, 2021 · 1 comment

Comments

@YasserGersy
Copy link

I have the following yaml

    matchers:
      - type: status
        status:
          - 200
          - 400
        condition: or
      - type: regex
        regex:
          - "((u|g)id|groups)=[0-9]{1,4}\\([a-z0-9]+\\)"
        part: body

Which gets deserialized to an object of matchers : when i invoke matchers[0].regex[0]: it returns a different value , the pattern was unescaped to :

((u|g)id|groups)=[0-9]{1,4}\([a-z0-9]+\)

Which has a different meaning.

@EdwardCooke
Copy link
Collaborator

In the spec, section 5.7,

Note that escape sequences are only interpreted in [double-quoted scalars](https://yaml.org/spec/1.2.2/#double-quoted-style). In all other [scalar styles](https://yaml.org/spec/1.2.2/#node-styles), the “\” character has no special meaning and non-[printable](https://yaml.org/spec/1.2.2/#character-set) characters are not available.

This is expected. To get this to work you would need to escape those escape characters, \\\\. Re-open this issue if that doesn't solve your problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants