fix: replace backslash before read_zip (#420)

* fix: replace backslash before read_zip

* Update docx-core/src/reader/read_zip.rs

* Update docx-core/src/reader/read_zip.rs

* Update docx-core/src/reader/read_zip.rs

Co-authored-by: bokuweb <bokuweb12@gmail.com>
main
Lilin Lao 2022-01-27 13:47:54 +08:00 committed by GitHub
parent 53aee2fa11
commit 8ab5925bce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -6,7 +6,9 @@ pub fn read_zip(
archive: &mut zip::read::ZipArchive<Cursor<&[u8]>>,
name: &str,
) -> Result<Vec<u8>, ReaderError> {
let mut p = name.to_owned();
let p = name.to_owned();
// Archives zipped on Windows keep '\' in paths, replace them to avoid zip error.
let mut p = str::replace(&p, "\\", "/");
if p.starts_with('/') {
p.remove(0);
}