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

When marshalling strings they are not escaped property #152

Closed
parkervcp opened this issue Jul 5, 2020 · 2 comments · Fixed by #158
Closed

When marshalling strings they are not escaped property #152

parkervcp opened this issue Jul 5, 2020 · 2 comments · Fixed by #158
Labels
bug Something isn't working

Comments

@parkervcp
Copy link

Example: https://play.golang.org/p/8eLm27d9NHe

I am escaping stars and backticks by having them wrapped in single/double quotes in my yaml file.

I have yaml in a file like bellow:

keyword: a test keyword
response:
- "**This line will print the first time** Fails to add when marshalling"
- "This line will be printed alone after marshalling and unmarshalling"

If you marshal it strips the outside quotes resulting in the following:

keyword: a test keyword
response:
- **This line will print the first time** Fails to add when marshalling
- This line will be printed alone after marshalling and unmarshalling

The result after marshalling is that the first line gets lost due to being parsed as a pointer when unmarshalling again. This also affects when reading and writing from files.

@goccy goccy added the bug Something isn't working label Jul 5, 2020
@fafeitsch
Copy link

This also seems to affect comment signs at the beginning of a string:

The following data does not get escaped properly:

  data := struct{
    Data string
    Message string
  }{
    Data: "#chocolate",
    Message: "I like #chocolate"
  }

The Data field is treated as a comment because its not escaped in the marshalled yaml file.

https://play.golang.org/p/-JsjGUty58n

@goccy
Copy link
Owner

goccy commented Aug 28, 2020

I fixed this issue with #158 and released as v1.8.1 .

Thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants