Partial download crashes with regex parse error
5long opened this issue · 2 comments
Environment
- OS: Arch Linux x86_64
- xh: version 0.20.1. both the Arch official package and the Github release binary xh-v0.20.1-x86_64-unknown-linux-musl.tar.gz can reproduce the issue.
Steps to Reproduce
- Prepare a partially downloaded file (doesn't need to be actual partial file, any non-zero file will do):
head -c100 > partial.iso
- Download a file from an HTTP server which supports partial download:
xh -p= -dcF --check-status -o partial.iso https://geo.mirror.pkgbuild.com/iso/latest/archlinux-x86_64.iso
Expected Result
Continues download from position 100 bytes. Works like curl -L -C - -f -o partial.iso https://geo.mirror.pkgbuild.com/iso/latest/archlinux-x86_64.iso
Actual Result
xh
crashes with the following message:
thread 'main' panicked at src/download.rs:107:5:
called `Result::unwrap()` on an `Err` value: Syntax(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
regex parse error:
^bytes (?P<first_byte_pos>\d+)-(?P<last_byte_pos>\d+)/(?:\*|(?P<complete_length>\d+))$
^^
error: Unicode-aware Perl class not found (make sure the unicode-perl feature is enabled)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Side note
Actually, this is already fixed with c9162b6. But there's no release available yet.
Oh, this one's nasty. We do have a test for this feature, but test builds include the assert_cmd
dependency, which includes the predicates
dependency, which enables the unicode-perl
feature for regex
, "fixing" the problem.
Two more things went wrong:
- Using
\d
instead of[0-9]
- Given that we did use
\d
, disabling the default features forregex
I wonder if we could use non-test builds for the end-to-end tests. But this feature only has a unit test, so it wouldn't have helped here. And missing features should mostly cause problems at compile time, not runtime, regex
is a special case.
#333 was a similar case. We should comb through our list of dependencies to look for other features we do use but don't declare.
This is now fixed in xh v0.21.0