nushell/crates/nu-command/src
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
..
bits add signature information when get help on one command (#7079) 2022-11-20 07:22:42 -06:00
bytes add signature information when get help on one command (#7079) 2022-11-20 07:22:42 -06:00
charting Split blocks and closures (#7075) 2022-11-10 21:21:49 +13:00
conversions add signature information when get help on one command (#7079) 2022-11-20 07:22:42 -06:00
core_commands add signature information when get help on one command (#7079) 2022-11-20 07:22:42 -06:00
database Split blocks and closures (#7075) 2022-11-10 21:21:49 +13:00
dataframe Limited mutable variables (#7089) 2022-11-11 19:51:08 +13:00
date add signature information when get help on one command (#7079) 2022-11-20 07:22:42 -06:00
deprecated Rename all?, any? and empty? (#6464) 2022-09-05 16:41:06 +02:00
env add signature information when get help on one command (#7079) 2022-11-20 07:22:42 -06:00
experimental Removes export env command (#6468) 2022-09-25 19:52:43 +03:00
filesystem Edit rm help messages (#7165) 2022-11-19 10:33:30 -08:00
filters add signature information when get help on one command (#7079) 2022-11-20 07:22:42 -06:00
formats Make json require string and pass around metadata (#7010) 2022-11-20 17:06:09 -08:00
generators Remove --separator from seq date (#7096) 2022-11-11 20:16:44 +13:00
hash add signature information when get help on one command (#7079) 2022-11-20 07:22:42 -06:00
math add signature information when get help on one command (#7079) 2022-11-20 07:22:42 -06:00
misc Replace all instances of 'column path' in help messages with 'cell path' (#7063) 2022-11-09 21:49:11 -08:00
network add signature information when get help on one command (#7079) 2022-11-20 07:22:42 -06:00
path add signature information when get help on one command (#7079) 2022-11-20 07:22:42 -06:00
platform add signature information when get help on one command (#7079) 2022-11-20 07:22:42 -06:00
random add signature information when get help on one command (#7079) 2022-11-20 07:22:42 -06:00
shells Refactor shell listing related code (#6262) 2022-08-08 06:31:24 -05:00
strings add signature information when get help on one command (#7079) 2022-11-20 07:22:42 -06:00
system Improve "Cannot convert argument to string" msg (#7161) 2022-11-18 21:33:01 +01:00
viewers fix #7145 (#7148) 2022-11-17 07:51:04 -06:00
default_context.rs new command url parse (#6854) and url subcommands tests (#7124) 2022-11-19 10:14:29 -08:00
example_test.rs Parser refactoring for improving pipelines (#7162) 2022-11-19 10:46:48 +13:00
input_handler.rs Replace all instances of 'column path' in help messages with 'cell path' (#7063) 2022-11-09 21:49:11 -08:00
lib.rs Refactor: introduce general operate commands to reduce duplicate code (#6879) 2022-10-29 16:29:46 -05:00
sort_utils.rs Improve CantFindColumn and ColumnAlreadyExists errors (#7164) 2022-11-19 09:35:55 -08:00