Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Unified Diff: third_party/zlib/google/zip.cc

Issue 2321823002: Exclude exe files while unzipping CRXes (Closed)
Patch Set: Ignore case Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/zlib/google/zip.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/zlib/google/zip.cc
diff --git a/third_party/zlib/google/zip.cc b/third_party/zlib/google/zip.cc
index f0180e533c8722a75f0da42352208a48fbf2c729..31f0ace7af89f0fdb997ef8309e7d3fcc131ed8d 100644
--- a/third_party/zlib/google/zip.cc
+++ b/third_party/zlib/google/zip.cc
@@ -94,6 +94,13 @@ bool ExcludeHiddenFilesFilter(const base::FilePath& file_path) {
namespace zip {
bool Unzip(const base::FilePath& src_file, const base::FilePath& dest_dir) {
+ return UnzipWithFilterCallback(src_file, dest_dir,
+ base::Bind(&ExcludeNoFilesFilter));
+}
+
+bool UnzipWithFilterCallback(const base::FilePath& src_file,
+ const base::FilePath& dest_dir,
+ const FilterCallback& filter_cb) {
ZipReader reader;
if (!reader.Open(src_file)) {
DLOG(WARNING) << "Failed to open " << src_file.value();
@@ -109,11 +116,17 @@ bool Unzip(const base::FilePath& src_file, const base::FilePath& dest_dir) {
<< reader.current_entry_info()->file_path().value();
return false;
}
- if (!reader.ExtractCurrentEntryIntoDirectory(dest_dir)) {
- DLOG(WARNING) << "Failed to extract "
+ if (filter_cb.Run(reader.current_entry_info()->file_path())) {
+ if (!reader.ExtractCurrentEntryIntoDirectory(dest_dir)) {
+ DLOG(WARNING) << "Failed to extract "
+ << reader.current_entry_info()->file_path().value();
+ return false;
+ }
+ } else {
+ DLOG(WARNING) << "Skipped file "
<< reader.current_entry_info()->file_path().value();
- return false;
}
+
if (!reader.AdvanceToNextEntry()) {
DLOG(WARNING) << "Failed to advance to the next file";
return false;
« no previous file with comments | « third_party/zlib/google/zip.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698