nushell/crates/nu-command/src
Leon 54dd65cfe1
Disallow encode's silent conversion to HTML entities (and add -i/--ignore-errors flag to re-allow it) (#7738)
# Description

Closes #7514.

* For both `encode` and `decode`: add a special case allowing `utf16` as
a valid alias for `utf-16` (just as `utf-8` has `utf8`).
* For `encode` , make it an error when encodings_rs replaces characters
outside the given encoding with HTML entities
* For `encode` , add `-i`/`--ignore-errors` flag to bring back this
behaviour.

Note: `--ignore-errors` does NOT ignore the error for using a wrong
encoding label like `uft8`

# User-Facing Changes

See above.

# Tests + Formatting

Don't forget to add tests that cover your changes.

Make sure you've run and fixed any issues with these commands:

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# After Submitting

If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.

Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
2023-01-12 15:00:17 -06:00
..
bits Further cleanup of Span::test_data usage + span fixes (#7595) 2022-12-24 07:41:57 -06:00
bytes Fix typos by codespell (#7600) 2022-12-26 02:31:26 -05:00
charting Fix typos by codespell (#7600) 2022-12-26 02:31:26 -05:00
conversions Further cleanup of Span::test_data usage + span fixes (#7595) 2022-12-24 07:41:57 -06:00
core_commands Continue and Break on Try/Catch (#7683) 2023-01-05 21:41:51 +01:00
database Standardise the use of ShellError::UnsupportedInput and ShellError::TypeMismatch and add spans to every instance of the former (#7217) 2022-12-23 01:48:53 -05:00
dataframe Add search terms in random and expression categories (#7736) 2023-01-12 14:01:40 +01:00
date Add extra_usage messages for subcommand-only commands (#7594) 2022-12-24 07:16:29 -06:00
deprecated Remove math eval command (#7284) 2023-01-04 23:50:18 +01:00
env Fix an example of env command (#7603) 2022-12-26 16:40:34 +08:00
experimental Change instances of Value::string("foo", Span::test_data()) to Value::test_string("foo") (#7592) 2022-12-24 10:25:38 +01:00
filesystem Progress bar Implementation (#7661) 2023-01-10 20:57:48 -05:00
filters [Chore] cleanup in where implementation (#7679) 2023-01-04 22:50:02 +01:00
formats Support redirect err and out to different streams (#7685) 2023-01-12 10:22:30 +01:00
generators Further cleanup of Span::test_data usage + span fixes (#7595) 2022-12-24 07:41:57 -06:00
hash Add extra_usage messages for subcommand-only commands (#7594) 2022-12-24 07:16:29 -06:00
math Remove math eval command (#7284) 2023-01-04 23:50:18 +01:00
misc Add more input/output type annotations (#7532) 2022-12-21 20:20:46 +01:00
network Progress bar Implementation (#7661) 2023-01-10 20:57:48 -05:00
path spanned error on path exists command (#7717) 2023-01-12 06:56:39 -06:00
platform Fix typos by codespell (#7600) 2022-12-26 02:31:26 -05:00
random Add search terms in random and expression categories (#7736) 2023-01-12 14:01:40 +01:00
shells Add more input/output type annotations (#7532) 2022-12-21 20:20:46 +01:00
strings Disallow encode's silent conversion to HTML entities (and add -i/--ignore-errors flag to re-allow it) (#7738) 2023-01-12 15:00:17 -06:00
system don't expand tilde if we quote external arguments (#7711) 2023-01-11 19:14:19 -05:00
viewers Fix generated doc for explore commands (#7723) 2023-01-11 11:17:12 +08:00
default_context.rs Url encode to escape special characters (#7664) 2023-01-05 19:24:38 +01:00
example_test.rs Make stream info visible to users in describe (#7589) 2023-01-03 21:08:05 -08:00
input_handler.rs Standardise the use of ShellError::UnsupportedInput and ShellError::TypeMismatch and add spans to every instance of the former (#7217) 2022-12-23 01:48:53 -05:00
lib.rs Progress bar Implementation (#7661) 2023-01-10 20:57:48 -05:00
progress_bar.rs Progress bar Implementation (#7661) 2023-01-10 20:57:48 -05:00
sort_utils.rs Further cleanup of Span::test_data usage + span fixes (#7595) 2022-12-24 07:41:57 -06:00