mirror of
https://github.com/nushell/nushell.git
synced 2025-08-18 09:29:48 +02:00
Quote strings containing =
(#16440)
Fixes nushell/nushell#16438 ## Release notes summary - What our users need to know Previously, a record key `=` would not be quoted in `to nuon`, producing invalid nuon output. It wasn't quoted in other string values either, but it didn't cause problems there. Now any string containing `=` gets quoted.
This commit is contained in:
@@ -515,6 +515,19 @@ fn quotes_some_strings_necessarily() {
|
||||
assert_eq!(actual.out, "list<string>");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn quotes_some_strings_necessarily_in_record_keys() {
|
||||
let actual = nu!(pipeline(
|
||||
r#"
|
||||
['=', 'a=', '=a'] | each {
|
||||
{$in : 42}
|
||||
} | reduce {|elt, acc| $acc | merge $elt} | to nuon | from nuon | columns | describe
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "list<string>");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn read_code_should_fail_rather_than_panic() {
|
||||
let actual = nu!(cwd: "tests/fixtures/formats", pipeline(
|
||||
|
@@ -2,12 +2,12 @@ use fancy_regex::Regex;
|
||||
use std::sync::LazyLock;
|
||||
|
||||
// This hits, in order:
|
||||
// • Any character of []:`{}#'";()|$,.!?
|
||||
// • Any character of []:`{}#'";()|$,.!?=
|
||||
// • Any digit (\d)
|
||||
// • Any whitespace (\s)
|
||||
// • Case-insensitive sign-insensitive float "keywords" inf, infinity and nan.
|
||||
static NEEDS_QUOTING_REGEX: LazyLock<Regex> = LazyLock::new(|| {
|
||||
Regex::new(r#"[\[\]:`\{\}#'";\(\)\|\$,\.\d\s!?]|(?i)^[+\-]?(inf(inity)?|nan)$"#)
|
||||
Regex::new(r#"[\[\]:`\{\}#'";\(\)\|\$,\.\d\s!?=]|(?i)^[+\-]?(inf(inity)?|nan)$"#)
|
||||
.expect("internal error: NEEDS_QUOTING_REGEX didn't compile")
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user