-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Fix quoting in to nuon
and refactor quoting functions
#14180
Conversation
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
f0afd26
to
c377478
Compare
@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 nuon
simply wrapped column names in'"'
instead of callingescape_quote_string
.As part of this change, I also moved the functions related to quoting (
needs_quoting
andescape_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 nuon
now properly escapes quotes in column names.Tests + Formatting
All tests pass, including workspace and stdlib tests.
After Submitting