Skip to content
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

Avoid panicking on invalid UTF-8 in DYM args #1483

Closed
wants to merge 1 commit into from

Conversation

kornelski
Copy link
Contributor

@kornelski kornelski commented Jun 2, 2019

cargo --help`printf "\\x8d00"`

panics, because "did you mean?" tries to use the arg with an invalid codepoint. It's an invalid user input, not a programmer bug, so IMHO it shouldn't cause a panic.

This fix uses to_string_lossy, so this case displays as:

error: Found argument '--help�00' which wasn't expected, or isn't valid in this context
Did you mean --help?

Since that's an error case, the lossiness shouldn't be an issue, and the correction is still useful.

Related to #751

@kornelski kornelski changed the title Avoid panicking on invalid UTF-8 in args Avoid panicking on invalid UTF-8 in DYM args Jun 2, 2019
@erickt
Copy link
Contributor

erickt commented Jun 20, 2019

fyi, the v2 branch has been frozen. can you migrate this PR to the v3-master branch?

@kornelski kornelski closed this Jul 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants