-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Fix utf8 length handling for shellwords #5738
Conversation
I see it... thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch! Mixed up utf-8 and utf-32 again :D
|
||
#[test] | ||
fn test_multibyte_at_end() { | ||
assert_eq!(Shellwords::from("𒀀").parts(), &["𒀀"]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I liked your examples in the PR description, let's add cases for them to make sure we don't have regressions in the future 👍
assert_eq!(Shellwords::from("𒀀").parts(), &["𒀀"]); | |
assert_eq!(Shellwords::from("𒀀").parts(), &["𒀀"]); | |
assert_eq!(Shellwords::from(":sh echo 𒀀").parts(), &[":sh", "echo", "𒀀"]); | |
assert_eq!(Shellwords::from(":sh echo hello𒀀").parts(), &[":sh", "echo", "hello𒀀"]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the change as a separate commit as it is generally cleaner to review (as opposed to an amend). I can squash them if you want. What is the general preference for this project?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reviewers generally squash themselves for small PRs like this if they find it necessary. I don't think it matters much either way,
9bd8cef
to
99dfa62
Compare
If the last argument to shellwords ends in a multibyte utf8 character the entire argument will be dropped. e.g. `:sh echo test1 test2𒀀` will only output `test1` Add additional tests based on the code review feedback
99dfa62
to
fa28198
Compare
(Force pushed without changes to trigger CI. I'm not sure why it didn't run the first time 🤔) |
If the last argument to shellwords ends in a multibyte utf8 character the entire argument will be dropped.
e.g.
:sh echo test1 test2𒀀
will only outputtest1