- Notifications
You must be signed in to change notification settings - Fork 0
Support password-protected zip files#1
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
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
c8e527497995b0208cde3c04137fFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -104,7 +104,11 @@ class GeneratedTask(BaseTask): | ||
| )); | ||
| out.push_str(" contents = f.read()\n"); | ||
| } | ||
| CandidateSource::Zip { archive, member } => { | ||
| CandidateSource::Zip { | ||
| archive, | ||
| member, | ||
| password, | ||
| } => { | ||
| let archive_name = archive | ||
| .file_name() | ||
| .map(|s| s.to_string_lossy()) | ||
| @@ -114,7 +118,20 @@ class GeneratedTask(BaseTask): | ||
| out.push_str(&format!( | ||
| " with zipfile.ZipFile(os.path.join(in_dir, {py_archive})) as z:\n" | ||
| )); | ||
| out.push_str(&format!(" with z.open({py_member}) as f:\n")); | ||
| if let Some(pw) = password { | ||
| let py_pw = py_str(pw); | ||
| out.push_str( | ||
| " # NOTE: zipfile only supports ZipCrypto; AES-encrypted\n", | ||
| ); | ||
| out.push_str( | ||
| " # archives need pyzipper or another AES-capable library.\n", | ||
| ); | ||
| out.push_str(&format!( | ||
| " with z.open({py_member}, pwd={py_pw}.encode()) as f:\n" | ||
| )); | ||
| } else { | ||
| out.push_str(&format!(" with z.open({py_member}) as f:\n")); | ||
| } | ||
pathawks marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| out.push_str(" contents = f.read()\n"); | ||
| } | ||
| CandidateSource::Kpka { archive, index } => { | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -235,7 +235,11 @@ pub enum CandidateSource { | ||
| /// Single file decompressed from a gzip stream. | ||
| Gzip { archive: PathBuf }, | ||
| /// One member extracted from a zip archive. | ||
| Zip { archive: PathBuf, member: String }, | ||
| Zip { | ||
| archive: PathBuf, | ||
| member: String, | ||
| password: Option<String>, | ||
| }, | ||
pathawks marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| /// Decompressed from an LZMA/XZ block found at `offset` inside `parent`. | ||
| Lzma { parent: PathBuf, offset: usize }, | ||
| /// One entry extracted from a KPKA/PAK archive (index is entry ordinal, 0-based). | ||
| @@ -268,7 +272,9 @@ impl std::fmt::Display for Candidate { | ||
| .unwrap_or("???".into()); | ||
| write!(f, "[gzip in {}]", a)?; | ||
| } | ||
| CandidateSource::Zip { archive, member } => { | ||
| CandidateSource::Zip { | ||
| archive, member, .. | ||
| } => { | ||
| let a = archive | ||
| .file_name() | ||
| .map(|s| s.to_string_lossy()) | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.