Skip to content

toml: fix crlf escape check #24329

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

Merged
merged 2 commits into from
Apr 26, 2025

Conversation

kbkpbot
Copy link
Contributor

@kbkpbot kbkpbot commented Apr 26, 2025

Fix #24328

Copy link

Connected to Huly®: V_0.6-22705

Comment on lines +4 to +8
toml_txt := 'str1 = """tcc \\\r\nabc \\\r\n123"""'
toml_doc := toml.parse_text(toml_txt) or { panic(err) }

value := toml_doc.value('str1').string()
assert value == 'tcc abc 123'
Copy link
Contributor

@larpon larpon Apr 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this not be a string printed like this?:

assert value == 'tcc \
abc \
123'

According to https://toml.io/en/v1.0.0#string it should be parsed as a multi-line basic string.
And a basic string should show a literal \ if you escape it with \. So """tcc \\\r\nabc \\\r\n123""" should become: tcc \\r\nabc \\r\n123 when "rendered"?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am honestly a little rusty in the spec since I implemented the toml module and I am uncertain if \r\n should result in just \n on unix and \r\n on windows 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When creating toml file under Windows, if has no this patch , it is simply can't write multiline string.
like this :

str1 = """ a \
      b \
     c
"""

@spytheman spytheman merged commit d9b808c into vlang:master Apr 26, 2025
64 checks passed
@kbkpbot kbkpbot deleted the fix-toml-multiline-line-end-slash branch May 31, 2025 09:10
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

Successfully merging this pull request may close these issues.

toml: check_quoted_escapes unknown basic string escape character
3 participants