Merge branch 'master' into utf8_extra_fields
This commit is contained in:
commit
c8d1cb905f
5 changed files with 22 additions and 39 deletions
14
Cargo.toml
14
Cargo.toml
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "zip"
|
name = "zip"
|
||||||
version = "2.1.1"
|
version = "2.1.2"
|
||||||
authors = [
|
authors = [
|
||||||
"Mathijs van de Nes <git@mathijs.vd-nes.nl>",
|
"Mathijs van de Nes <git@mathijs.vd-nes.nl>",
|
||||||
"Marli Frost <marli@frost.red>",
|
"Marli Frost <marli@frost.red>",
|
||||||
|
@ -30,34 +30,34 @@ aes = { version = "0.8.4", optional = true }
|
||||||
bzip2 = { version = "0.4.4", optional = true }
|
bzip2 = { version = "0.4.4", optional = true }
|
||||||
chrono = { version = "0.4.38", optional = true }
|
chrono = { version = "0.4.38", optional = true }
|
||||||
constant_time_eq = { version = "0.3.0", optional = true }
|
constant_time_eq = { version = "0.3.0", optional = true }
|
||||||
crc32fast = "1.4.0"
|
crc32fast = "1.4.2"
|
||||||
displaydoc = { version = "0.2.4", default-features = false }
|
displaydoc = { version = "0.2.4", default-features = false }
|
||||||
flate2 = { version = "1.0.28", default-features = false, optional = true }
|
flate2 = { version = "1.0.30", default-features = false, optional = true }
|
||||||
indexmap = "2"
|
indexmap = "2"
|
||||||
hmac = { version = "0.12.1", optional = true, features = ["reset"] }
|
hmac = { version = "0.12.1", optional = true, features = ["reset"] }
|
||||||
memchr = "2.7.2"
|
memchr = "2.7.2"
|
||||||
pbkdf2 = { version = "0.12.2", optional = true }
|
pbkdf2 = { version = "0.12.2", optional = true }
|
||||||
rand = { version = "0.8.5", optional = true }
|
rand = { version = "0.8.5", optional = true }
|
||||||
sha1 = { version = "0.10.6", optional = true }
|
sha1 = { version = "0.10.6", optional = true }
|
||||||
thiserror = "1.0.48"
|
thiserror = "1.0.61"
|
||||||
time = { workspace = true, optional = true, features = [
|
time = { workspace = true, optional = true, features = [
|
||||||
"std",
|
"std",
|
||||||
] }
|
] }
|
||||||
zeroize = { version = "1.6.0", optional = true, features = ["zeroize_derive"] }
|
zeroize = { version = "1.8.1", optional = true, features = ["zeroize_derive"] }
|
||||||
zstd = { version = "0.13.1", optional = true, default-features = false }
|
zstd = { version = "0.13.1", optional = true, default-features = false }
|
||||||
zopfli = { version = "0.8.1", optional = true }
|
zopfli = { version = "0.8.1", optional = true }
|
||||||
deflate64 = { version = "0.1.8", optional = true }
|
deflate64 = { version = "0.1.8", optional = true }
|
||||||
lzma-rs = { version = "0.3.0", default-features = false, optional = true }
|
lzma-rs = { version = "0.3.0", default-features = false, optional = true }
|
||||||
|
|
||||||
[target.'cfg(any(all(target_arch = "arm", target_pointer_width = "32"), target_arch = "mips", target_arch = "powerpc"))'.dependencies]
|
[target.'cfg(any(all(target_arch = "arm", target_pointer_width = "32"), target_arch = "mips", target_arch = "powerpc"))'.dependencies]
|
||||||
crossbeam-utils = "0.8.19"
|
crossbeam-utils = "0.8.20"
|
||||||
|
|
||||||
[target.'cfg(fuzzing)'.dependencies]
|
[target.'cfg(fuzzing)'.dependencies]
|
||||||
arbitrary = { version = "1.3.2", features = ["derive"] }
|
arbitrary = { version = "1.3.2", features = ["derive"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
bencher = "0.1.5"
|
bencher = "0.1.5"
|
||||||
getrandom = { version = "0.2.14", features = ["js", "std"] }
|
getrandom = { version = "0.2.15", features = ["js", "std"] }
|
||||||
walkdir = "2.5.0"
|
walkdir = "2.5.0"
|
||||||
time = { workspace = true, features = ["formatting", "macros"] }
|
time = { workspace = true, features = ["formatting", "macros"] }
|
||||||
anyhow = "1"
|
anyhow = "1"
|
||||||
|
|
|
@ -42,12 +42,12 @@ fn real_main() -> i32 {
|
||||||
let method = match args.compression_method {
|
let method = match args.compression_method {
|
||||||
CompressionMethod::Stored => zip::CompressionMethod::Stored,
|
CompressionMethod::Stored => zip::CompressionMethod::Stored,
|
||||||
CompressionMethod::Deflated => {
|
CompressionMethod::Deflated => {
|
||||||
#[cfg(not(feature = "deflate"))]
|
#[cfg(not(feature = "deflate-flate2"))]
|
||||||
{
|
{
|
||||||
println!("The `deflate` feature is not enabled");
|
println!("The `deflate-flate2` feature is not enabled");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#[cfg(feature = "deflate")]
|
#[cfg(feature = "deflate-flate2")]
|
||||||
zip::CompressionMethod::Deflated
|
zip::CompressionMethod::Deflated
|
||||||
}
|
}
|
||||||
CompressionMethod::DeflatedZlib => {
|
CompressionMethod::DeflatedZlib => {
|
||||||
|
|
|
@ -24,11 +24,7 @@ use std::ops::Deref;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::sync::{Arc, OnceLock};
|
use std::sync::{Arc, OnceLock};
|
||||||
|
|
||||||
#[cfg(any(
|
#[cfg(feature = "deflate-flate2")]
|
||||||
feature = "deflate",
|
|
||||||
feature = "deflate-zlib",
|
|
||||||
feature = "deflate-zlib-ng"
|
|
||||||
))]
|
|
||||||
use flate2::read::DeflateDecoder;
|
use flate2::read::DeflateDecoder;
|
||||||
|
|
||||||
#[cfg(feature = "deflate64")]
|
#[cfg(feature = "deflate64")]
|
||||||
|
|
|
@ -43,7 +43,7 @@ pub trait LittleEndianWriteExt: Write {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<W: Write> LittleEndianWriteExt for W {}
|
impl<W: Write + ?Sized> LittleEndianWriteExt for W {}
|
||||||
|
|
||||||
/// Helper methods for reading unsigned integers in little-endian form.
|
/// Helper methods for reading unsigned integers in little-endian form.
|
||||||
pub trait LittleEndianReadExt: Read {
|
pub trait LittleEndianReadExt: Read {
|
||||||
|
|
33
src/write.rs
33
src/write.rs
|
@ -27,11 +27,7 @@ use std::mem;
|
||||||
use std::str::{from_utf8, Utf8Error};
|
use std::str::{from_utf8, Utf8Error};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
#[cfg(any(
|
#[cfg(feature = "deflate-flate2")]
|
||||||
feature = "deflate",
|
|
||||||
feature = "deflate-zlib",
|
|
||||||
feature = "deflate-zlib-ng"
|
|
||||||
))]
|
|
||||||
use flate2::{write::DeflateEncoder, Compression};
|
use flate2::{write::DeflateEncoder, Compression};
|
||||||
|
|
||||||
#[cfg(feature = "bzip2")]
|
#[cfg(feature = "bzip2")]
|
||||||
|
@ -881,9 +877,12 @@ impl<W: Write + Seek> ZipWriter<W> {
|
||||||
));
|
));
|
||||||
};
|
};
|
||||||
if pad_length >= 4 {
|
if pad_length >= 4 {
|
||||||
// Add an extra field to the extra_data
|
// Add an extra field to the extra_data, per APPNOTE 4.6.11
|
||||||
let pad_body = vec![0; pad_length - 4];
|
let mut pad_body = vec![0; pad_length - 4];
|
||||||
writer.write_all(b"za").map_err(ZipError::from)?; // 0x617a
|
if pad_body.len() >= 2 {
|
||||||
|
[pad_body[0], pad_body[1]] = options.alignment.to_le_bytes();
|
||||||
|
}
|
||||||
|
writer.write_u16_le(0xa11e)?;
|
||||||
writer
|
writer
|
||||||
.write_u16_le(pad_body.len() as u16)
|
.write_u16_le(pad_body.len() as u16)
|
||||||
.map_err(ZipError::from)?;
|
.map_err(ZipError::from)?;
|
||||||
|
@ -1566,11 +1565,7 @@ impl<W: Write + Seek> GenericZipWriter<W> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(
|
#[cfg(feature = "deflate-flate2")]
|
||||||
feature = "deflate",
|
|
||||||
feature = "deflate-zlib",
|
|
||||||
feature = "deflate-zlib-ng",
|
|
||||||
))]
|
|
||||||
{
|
{
|
||||||
Ok(Box::new(move |bare| {
|
Ok(Box::new(move |bare| {
|
||||||
GenericZipWriter::Deflater(DeflateEncoder::new(
|
GenericZipWriter::Deflater(DeflateEncoder::new(
|
||||||
|
@ -1630,11 +1625,7 @@ impl<W: Write + Seek> GenericZipWriter<W> {
|
||||||
fn switch_to(&mut self, make_new_self: SwitchWriterFunction<W>) -> ZipResult<()> {
|
fn switch_to(&mut self, make_new_self: SwitchWriterFunction<W>) -> ZipResult<()> {
|
||||||
let bare = match mem::replace(self, Closed) {
|
let bare = match mem::replace(self, Closed) {
|
||||||
Storer(w) => w,
|
Storer(w) => w,
|
||||||
#[cfg(any(
|
#[cfg(feature = "deflate-flate2")]
|
||||||
feature = "deflate",
|
|
||||||
feature = "deflate-zlib",
|
|
||||||
feature = "deflate-zlib-ng"
|
|
||||||
))]
|
|
||||||
GenericZipWriter::Deflater(w) => w.finish()?,
|
GenericZipWriter::Deflater(w) => w.finish()?,
|
||||||
#[cfg(feature = "deflate-zopfli")]
|
#[cfg(feature = "deflate-zopfli")]
|
||||||
GenericZipWriter::ZopfliDeflater(w) => w.finish()?,
|
GenericZipWriter::ZopfliDeflater(w) => w.finish()?,
|
||||||
|
@ -1662,11 +1653,7 @@ impl<W: Write + Seek> GenericZipWriter<W> {
|
||||||
fn ref_mut(&mut self) -> Option<&mut dyn Write> {
|
fn ref_mut(&mut self) -> Option<&mut dyn Write> {
|
||||||
match self {
|
match self {
|
||||||
Storer(ref mut w) => Some(w as &mut dyn Write),
|
Storer(ref mut w) => Some(w as &mut dyn Write),
|
||||||
#[cfg(any(
|
#[cfg(feature = "deflate-flate2")]
|
||||||
feature = "deflate",
|
|
||||||
feature = "deflate-zlib",
|
|
||||||
feature = "deflate-zlib-ng"
|
|
||||||
))]
|
|
||||||
GenericZipWriter::Deflater(ref mut w) => Some(w as &mut dyn Write),
|
GenericZipWriter::Deflater(ref mut w) => Some(w as &mut dyn Write),
|
||||||
#[cfg(feature = "deflate-zopfli")]
|
#[cfg(feature = "deflate-zopfli")]
|
||||||
GenericZipWriter::ZopfliDeflater(w) => Some(w as &mut dyn Write),
|
GenericZipWriter::ZopfliDeflater(w) => Some(w as &mut dyn Write),
|
||||||
|
|
Loading…
Add table
Reference in a new issue