Fix quoting in to nuon and refactor quoting functions#14180
Fix quoting in to nuon and refactor quoting functions#14180fdncred merged 2 commits intonushell:mainfrom aionescu:improve-quoting
to nuon and refactor quoting functions#14180Conversation
|
I found the issue fixed by this PR while working on #13362. The quoting functions refactor isn't strictly needed for this fix, but it will be helpful for the follow-up PR fixing the linked issue, so I decided to sneak it in here. If you think it's better to split it into a separate PR, please let me know.
|
| lscolors = { workspace = true, default-features = false, features = ["nu-ansi-term"] } | ||
| log = { workspace = true } | ||
| num-format = { workspace = true } | ||
| once_cell = { workspace = true } |
There was a problem hiding this comment.
maybe i'm wrong but i thought this once_cell stuff was built into rust now?
rust-lang/rust#105587
https://doc.rust-lang.org/core/cell/struct.OnceCell.html
https://doc.rust-lang.org/core/cell/struct.LazyCell.html
maybe it's not the same? we probably already have a dependency on once_cell but it would be nice to remove all these (in a separate pr) if it's built in now.
There was a problem hiding this comment.
Oh, I didn't know that. I just moved the dependency from crate nuon to crate nu-utils, but I'll check if it can be removed entirely.
There was a problem hiding this comment.
I've taken a look, and we have multiple crates that depend on once_cell for Lazy. I'll make a separate PR to replace them with the now-built-in LazyCell once this gets merged.
|
Sorry, there's a conflict now. |
|
@fdncred Just fixed it. |
|
Thanks |
Description
This PR fixes the quoting and escaping of column names in
to nuon. Before the PR, column names with quotes inside them would get quoted, but not escaped:After this PR, the quote is escaped properly:
The cause of the issue was that
to nuonsimply wrapped column names in'"'instead of callingescape_quote_string.As part of this change, I also moved the functions related to quoting (
needs_quotingandescape_quote_string) intonu-utils, since previously they were defined in very ad-hoc places (and, in the case ofescape_quote_string, it was defined multiple times with the same body!).User-Facing Changes
to nuonnow properly escapes quotes in column names.Tests + Formatting
All tests pass, including workspace and stdlib tests.
After Submitting