Skip to content

Update zip dependency and fix deprecation warnings#3617

Merged
antiochp merged 1 commit intomimblewimble:masterfrom
GeneFerneau:zip
Apr 13, 2021
Merged

Update zip dependency and fix deprecation warnings#3617
antiochp merged 1 commit intomimblewimble:masterfrom
GeneFerneau:zip

Conversation

@GeneFerneau
Copy link
Copy Markdown
Contributor

Update zip crate to latest version, and fix deprecation warnings using functionally equivalent APIs

Update zip crate to latest version, and fix deprecation warnings
using functionally equivalent APIs
@antiochp antiochp self-requested a review March 29, 2021 19:25
for x in files {
if let Ok(file) = archive.by_name(x.to_str().expect("valid path")) {
let path = dest.join(file.sanitized_name());
let path = dest.join(file.mangled_name());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is enclosed_name a better option here, based on the doc comments?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked at that too, but we actually want the side-effects of mangled_name.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm 👍 on replacing sanitized_name with mangled_name based on the deprecated sanitized_name simply delegating to mangled_name.

But it might be worth revisiting with a separate PR to consider replacing with enclosed_name.

From the docs referenced by @trevyn -

    /// This will read well-formed ZIP files correctly, and is resistant
    /// to path-based exploits. It is recommended over
    /// [`ZipFile::mangled_name`].

if let Ok(file) = File::open(file_path.clone()) {
info!("compress: {:?} -> {:?}", file_path, x);
writer.get_mut().start_file_from_path(x, options)?;
writer.get_mut().start_file(path_to_string(x), options)?;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would just x.to_str() work here? We generate the path, so it shouldn't need to be sanitized with the path_to_string function, right?

Copy link
Copy Markdown
Contributor Author

@GeneFerneau GeneFerneau Apr 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

path_to_string performs extra checks that x.to_str() does not, like normalizing the path. I was also going for functional equivalence to what the previous function does. If you look at zip-rs source, this is exactly what the start_file_from_path function does internally.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@phyro
Copy link
Copy Markdown
Member

phyro commented Apr 12, 2021

@GeneFerneau check the comments when you find the time, let's get this one in if it is easy to resolve those 👍

@GeneFerneau
Copy link
Copy Markdown
Contributor Author

@GeneFerneau check the comments when you find the time, let's get this one in if it is easy to resolve those +1

Addressed the comments. Let me know if that answers your questions.

Copy link
Copy Markdown
Member

@antiochp antiochp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@antiochp antiochp merged commit 1b8acee into mimblewimble:master Apr 13, 2021
@antiochp antiochp mentioned this pull request May 6, 2021
bayk added a commit to mwcproject/mwc-node that referenced this pull request Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants