Skip to content

toml: fix crlf escape check#24329

Merged
spytheman merged 2 commits into
vlang:masterfrom
kbkpbot:fix-toml-multiline-line-end-slash
Apr 26, 2025
Merged

toml: fix crlf escape check#24329
spytheman merged 2 commits into
vlang:masterfrom
kbkpbot:fix-toml-multiline-line-end-slash

Conversation

@kbkpbot

@kbkpbot kbkpbot commented Apr 26, 2025

Copy link
Copy Markdown
Contributor

Fix #24328

@huly-for-github

Copy link
Copy Markdown

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'

@larpon larpon Apr 26, 2025

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
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
@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