nushell/crates/nu-command
Martin Habovštiak d9d6cea5a9
Make json require string and pass around metadata (#7010)
* Make json require string and pass around metadata

The json deserializer was accepting any inputs by coercing non-strings
into strings. As an example, if the input was `[1, 2]` the coercion
would turn into `[12]` and deserialize as a list containing number
twelve instead of a list of two numbers, one and two. This could lead
to silent data corruption.

Aside from that pipeline metadata wasn't passed aroud.

This commit fixes the type issue by adding a strict conversion
function that errors if the input type is not a string or external
stream. It then uses this function instead of the original
`collect_string()`. In addition, this function returns the pipeline
metadata so it can be passed along.

* Make other formats require string

The problem with json coercing non-string types to string was present in
all other text formats. This reuses the `collect_string_strict` function
to fix them.

* `IntoPipelineData` cleanup

The method `into_pipeline_data_with_metadata` can now be conveniently
used.
2022-11-20 17:06:09 -08:00
..
assets refactor html module (#5246) 2022-04-20 08:50:14 -05:00
proptest-regressions/format_conversions add tests, deal with pipes, newlines, tabs for to nuon (#6391) 2022-09-01 14:08:19 +02:00
src Make json require string and pass around metadata (#7010) 2022-11-20 17:06:09 -08:00
tests add signature information when get help on one command (#7079) 2022-11-20 07:22:42 -06:00
build.rs Fix panic when building without git (#6289) 2022-08-10 10:31:12 -05:00
Cargo.toml Fix needs_quotes() in to nuon (closes #6989) (#7056) 2022-11-19 12:09:39 +01:00
LICENSE Include license text in all crates (#5094) 2022-04-08 10:47:13 +02:00