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

[Yaml ] Use double-quoted for DUMP_MULTI_LINE_LITERAL_BLOCK to allow more characters #39682

Open
geek-merlin opened this issue Jan 2, 2021 · 14 comments
Labels
RFC RFC = Request For Comments (proposals about features that you want to be discussed) Yaml

Comments

@geek-merlin
Copy link

geek-merlin commented Jan 2, 2021

Background

Yaml is nice for dumping config in a human-readable and -editable format. E.g. Drupal uses it extensively.

In that context, dumping e.g. CSS as multiline is essential for human-readability.

As discovered in #25842, and confirmed on SO and yaml-multiline.info,

  • Yaml multiline is not capable of handling arbitrary characters: escaped unicode characters like \u1234, also "\r" is excluded in current code
  • Double-quoted iscapable of handling arbitrary escaped unicode values, and can span multiple lines

Researched thoroughly, so which are valid multiline literal characters:

  • l-nb-literal-text = ...nb-char+
  • nb-char = c-printable - b-char - c-byte-order-mark = #x9 | [#x20-#x7E] | #x85 | [#xA0-#xD7FF] | [#xE000-#xFFFD] - #xFEFF | [#x10000-#x10FFFF]

As of current code,
a) "\r" is excluded in current code, which means that any multiline string containing it will not be dumped as multiline, but as quoted scalar.
b) All other (non-printable) characters are invalid as multiline literal, so current code will produce invalid yaml.

Which means

  • either we extend the "\r" blacklist with above, so to rather
  • or switch to the following more robust format

Description

  • Do multiline dumping like shown below (or see this fiddle). So we get multiline readability capable to encode every unicode character.

Example

dquote 0: "one\n\
  two (after every litaral newline, we add an escaped yaml newline)"
dquote 1: "one\n\
  two\n\
  "
dquote 2: "one\n\
  two\n\
  \n\
  "
dquote with initial space: "  one  \n\
    two  \n\
  \  as we see, trailing spaces are no problem, but we need to escape initial spaces on non-first line.  "
@xabbuh xabbuh added RFC RFC = Request For Comments (proposals about features that you want to be discussed) Yaml labels Jan 2, 2021
@geek-merlin geek-merlin changed the title Implement DUMP_MULTI_LINE_DOUBLE_QUOTED (and deprecate DUMP_MULTI_LINE_LITERAL_BLOCK) [Yaml] Fix multiline dumps containing unicodeby using double quotes Jan 3, 2021
@geek-merlin geek-merlin changed the title [Yaml] Fix multiline dumps containing unicodeby using double quotes DUMP_MULTI_LINE_DOUBLE_QUOTED (and deprecate DUMP_MULTI_LINE_LITERAL_BLOCK) Jan 3, 2021
@geek-merlin geek-merlin changed the title DUMP_MULTI_LINE_DOUBLE_QUOTED (and deprecate DUMP_MULTI_LINE_LITERAL_BLOCK) Implement DUMP_MULTI_LINE_DOUBLE_QUOTED (and deprecate DUMP_MULTI_LINE_LITERAL_BLOCK) Jan 3, 2021
@geek-merlin geek-merlin changed the title Implement DUMP_MULTI_LINE_DOUBLE_QUOTED (and deprecate DUMP_MULTI_LINE_LITERAL_BLOCK) [Yaml ] Use double-quoted for DUMP_MULTI_LINE_LITERAL_BLOCK to make it robust and maintaineble Jan 4, 2021
@geek-merlin geek-merlin changed the title [Yaml ] Use double-quoted for DUMP_MULTI_LINE_LITERAL_BLOCK to make it robust and maintaineble [Yaml ] Use double-quoted for DUMP_MULTI_LINE_LITERAL_BLOCK to allow more characters Jan 4, 2021
@geek-merlin
Copy link
Author

OK some meta-comment on the lots of IS and title changes: While drilling deeper into the subject, my POV changed from OMG we must do this to This has some benefits WRT non-printable characters.

@carsonbot
Copy link

Thank you for this suggestion.
There has not been a lot of activity here for a while. Would you still like to see this feature?

@stof
Copy link
Member

stof commented Jul 5, 2021

@xabbuh what do you think about this ?

@carsonbot carsonbot removed the Stalled label Jul 5, 2021
@xabbuh
Copy link
Member

xabbuh commented Jul 8, 2021

This looks reasonable to me. @geek-merlin Would you like to give this a try?

@carsonbot
Copy link

Thank you for this suggestion.
There has not been a lot of activity here for a while. Would you still like to see this feature?

@geek-merlin
Copy link
Author

No time to prioritize this currently, but yes still wanted.

@carsonbot carsonbot removed the Stalled label Jan 19, 2022
@carsonbot
Copy link

Thank you for this suggestion.
There has not been a lot of activity here for a while. Would you still like to see this feature?

@andypost
Copy link

++ to fix it

@carsonbot carsonbot removed the Stalled label Aug 28, 2022
@carsonbot
Copy link

Thank you for this suggestion.
There has not been a lot of activity here for a while. Would you still like to see this feature?

@geek-merlin
Copy link
Author

Yes, a lot.

@carsonbot carsonbot removed the Stalled label Mar 2, 2023
@carsonbot
Copy link

Thank you for this suggestion.
There has not been a lot of activity here for a while. Would you still like to see this feature?

@geek-merlin
Copy link
Author

Alot...

@carsonbot carsonbot removed the Stalled label Sep 4, 2023
@carsonbot
Copy link

Thank you for this suggestion.
There has not been a lot of activity here for a while. Would you still like to see this feature?

@geek-merlin
Copy link
Author

Yupp

@carsonbot carsonbot removed the Stalled label Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFC RFC = Request For Comments (proposals about features that you want to be discussed) Yaml
Projects
None yet
Development

No branches or pull requests

5 participants