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

bat panics on invalid-utf8 filename #225

Closed
sharkdp opened this issue Aug 27, 2018 · 6 comments · Fixed by #825
Closed

bat panics on invalid-utf8 filename #225

sharkdp opened this issue Aug 27, 2018 · 6 comments · Fixed by #825
Labels
bug Something isn't working

Comments

@sharkdp
Copy link
Owner

sharkdp commented Aug 27, 2018

▶ RUST_BACKTRACE=1 bat test-invalid-utf8-$'\303'\(.txt
thread 'main' panicked at 'unexpected invalid UTF-8 code point', libcore/option.rs:960:5
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::print
             at libstd/sys_common/backtrace.rs:71
             at libstd/sys_common/backtrace.rs:59
   2: std::panicking::default_hook::{{closure}}
             at libstd/panicking.rs:211
   3: std::panicking::default_hook
             at libstd/panicking.rs:227
   4: std::panicking::rust_panic_with_hook
             at libstd/panicking.rs:511
   5: std::panicking::continue_panic_fmt
             at libstd/panicking.rs:426
   6: rust_begin_unwind
             at libstd/panicking.rs:337
   7: core::panicking::panic_fmt
             at libcore/panicking.rs:92
   8: core::option::expect_failed
             at libcore/option.rs:960
   9: clap::args::arg_matches::ArgMatches::values_of::to_str_slice
  10: <clap::args::arg_matches::Values<'a> as core::iter::iterator::Iterator>::next
  11: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter
  12: bat::run
  13: bat::main
  14: std::rt::lang_start::{{closure}}
  15: std::panicking::try::do_call
             at libstd/rt.rs:59
             at libstd/panicking.rs:310
  16: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:105
  17: std::rt::lang_start_internal
             at libstd/panicking.rs:289
             at libstd/panic.rs:392
             at libstd/rt.rs:58
  18: main
  19: __libc_start_main
  20: _start
@sharkdp sharkdp added the bug Something isn't working label Aug 27, 2018
@sharkdp
Copy link
Owner Author

sharkdp commented Aug 27, 2018

So, in principle, clap supports non-utf8 arguments. However, dealing with OsString and lots of platform-dependent code doesn't really seem to be worth the trouble just to fix this rather esoteric bug.

Yes, unix filenames can be non-utf8. But also, I'm happy to fight anyone who actually uses an abomination like this.

@sharkdp sharkdp closed this as completed Aug 27, 2018
@bdejean
Copy link

bdejean commented Feb 11, 2020

Hello, I'm sorry but that the first tool i've ever seen that cannot open file because the encoding isn't not valid. That limitation is not POSIX https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_170
And yes I run into very often when trying to display files coming from Windows or from zip files..
That's not nice.

@sharkdp
Copy link
Owner Author

sharkdp commented Feb 12, 2020

@bdejean I don't really like the attitude/sound of your post ("That's not nice", "that the first tool i've ever seen …").

That being said, this was rather easy to fix. Should be closed via #825.

@bdejean
Copy link

bdejean commented Feb 13, 2020

@sharkdp Hello and please accept my apology, i was merely reacting to your "I'm happy to fight anyone who actually uses an abomination like this". Thank you very much.

@sharkdp
Copy link
Owner Author

sharkdp commented Feb 13, 2020

@bdejean Absolutely. Hadn't read my own comment above and don't remember why I wrote that. Must have been frustrated by trying to implement this earlier 😄. Thanks!

@sharkdp
Copy link
Owner Author

sharkdp commented Mar 22, 2020

This has been fixed in bat 0.13.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants