Skip to content

Commit

Permalink
deps: update zlib to 1.3.0.1-motley-887bb57
Browse files Browse the repository at this point in the history
PR-URL: #53464
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
nodejs-github-bot authored and targos committed Sep 21, 2024
1 parent 88e7a1a commit a439535
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 67 deletions.
104 changes: 52 additions & 52 deletions deps/zlib/google/zip_internal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
#include <string.h>

#include <algorithm>
#include <string_view>

#include "base/containers/fixed_flat_set.h"
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/notreached.h"
#include "base/strings/string_piece.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"

Expand Down Expand Up @@ -398,64 +398,64 @@ Compression GetCompressionMethod(const base::FilePath& path) {
if (ext.empty())
return kDeflated;

using StringPiece = base::FilePath::StringPieceType;

// Skip the leading dot.
StringPiece ext_without_dot = ext;
base::FilePath::StringPieceType ext_without_dot = ext;
DCHECK_EQ(ext_without_dot.front(), FILE_PATH_LITERAL('.'));
ext_without_dot.remove_prefix(1);

// Well known filename extensions of files that a likely to be already
// compressed. The extensions are in lower case without the leading dot.
static constexpr auto kExts = base::MakeFixedFlatSet<StringPiece>({
FILE_PATH_LITERAL("3g2"), //
FILE_PATH_LITERAL("3gp"), //
FILE_PATH_LITERAL("7z"), //
FILE_PATH_LITERAL("7zip"), //
FILE_PATH_LITERAL("aac"), //
FILE_PATH_LITERAL("avi"), //
FILE_PATH_LITERAL("bz"), //
FILE_PATH_LITERAL("bz2"), //
FILE_PATH_LITERAL("crx"), //
FILE_PATH_LITERAL("gif"), //
FILE_PATH_LITERAL("gz"), //
FILE_PATH_LITERAL("jar"), //
FILE_PATH_LITERAL("jpeg"), //
FILE_PATH_LITERAL("jpg"), //
FILE_PATH_LITERAL("lz"), //
FILE_PATH_LITERAL("m2v"), //
FILE_PATH_LITERAL("m4p"), //
FILE_PATH_LITERAL("m4v"), //
FILE_PATH_LITERAL("mng"), //
FILE_PATH_LITERAL("mov"), //
FILE_PATH_LITERAL("mp2"), //
FILE_PATH_LITERAL("mp3"), //
FILE_PATH_LITERAL("mp4"), //
FILE_PATH_LITERAL("mpe"), //
FILE_PATH_LITERAL("mpeg"), //
FILE_PATH_LITERAL("mpg"), //
FILE_PATH_LITERAL("mpv"), //
FILE_PATH_LITERAL("ogg"), //
FILE_PATH_LITERAL("ogv"), //
FILE_PATH_LITERAL("png"), //
FILE_PATH_LITERAL("qt"), //
FILE_PATH_LITERAL("rar"), //
FILE_PATH_LITERAL("taz"), //
FILE_PATH_LITERAL("tb2"), //
FILE_PATH_LITERAL("tbz"), //
FILE_PATH_LITERAL("tbz2"), //
FILE_PATH_LITERAL("tgz"), //
FILE_PATH_LITERAL("tlz"), //
FILE_PATH_LITERAL("tz"), //
FILE_PATH_LITERAL("tz2"), //
FILE_PATH_LITERAL("vob"), //
FILE_PATH_LITERAL("webm"), //
FILE_PATH_LITERAL("wma"), //
FILE_PATH_LITERAL("wmv"), //
FILE_PATH_LITERAL("xz"), //
FILE_PATH_LITERAL("z"), //
FILE_PATH_LITERAL("zip"), //
});
static constexpr auto kExts =
base::MakeFixedFlatSet<base::FilePath::StringPieceType>({
FILE_PATH_LITERAL("3g2"), //
FILE_PATH_LITERAL("3gp"), //
FILE_PATH_LITERAL("7z"), //
FILE_PATH_LITERAL("7zip"), //
FILE_PATH_LITERAL("aac"), //
FILE_PATH_LITERAL("avi"), //
FILE_PATH_LITERAL("bz"), //
FILE_PATH_LITERAL("bz2"), //
FILE_PATH_LITERAL("crx"), //
FILE_PATH_LITERAL("gif"), //
FILE_PATH_LITERAL("gz"), //
FILE_PATH_LITERAL("jar"), //
FILE_PATH_LITERAL("jpeg"), //
FILE_PATH_LITERAL("jpg"), //
FILE_PATH_LITERAL("lz"), //
FILE_PATH_LITERAL("m2v"), //
FILE_PATH_LITERAL("m4p"), //
FILE_PATH_LITERAL("m4v"), //
FILE_PATH_LITERAL("mng"), //
FILE_PATH_LITERAL("mov"), //
FILE_PATH_LITERAL("mp2"), //
FILE_PATH_LITERAL("mp3"), //
FILE_PATH_LITERAL("mp4"), //
FILE_PATH_LITERAL("mpe"), //
FILE_PATH_LITERAL("mpeg"), //
FILE_PATH_LITERAL("mpg"), //
FILE_PATH_LITERAL("mpv"), //
FILE_PATH_LITERAL("ogg"), //
FILE_PATH_LITERAL("ogv"), //
FILE_PATH_LITERAL("png"), //
FILE_PATH_LITERAL("qt"), //
FILE_PATH_LITERAL("rar"), //
FILE_PATH_LITERAL("taz"), //
FILE_PATH_LITERAL("tb2"), //
FILE_PATH_LITERAL("tbz"), //
FILE_PATH_LITERAL("tbz2"), //
FILE_PATH_LITERAL("tgz"), //
FILE_PATH_LITERAL("tlz"), //
FILE_PATH_LITERAL("tz"), //
FILE_PATH_LITERAL("tz2"), //
FILE_PATH_LITERAL("vob"), //
FILE_PATH_LITERAL("webm"), //
FILE_PATH_LITERAL("wma"), //
FILE_PATH_LITERAL("wmv"), //
FILE_PATH_LITERAL("xz"), //
FILE_PATH_LITERAL("z"), //
FILE_PATH_LITERAL("zip"), //
});

if (kExts.count(ext_without_dot)) {
return kStored;
Expand Down
11 changes: 6 additions & 5 deletions deps/zlib/google/zip_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "third_party/zlib/google/zip_reader.h"

#include <algorithm>
#include <string_view>
#include <utility>

#include "base/check.h"
Expand All @@ -15,7 +16,6 @@
#include "base/logging.h"
#include "base/numerics/safe_conversions.h"
#include "base/strings/strcat.h"
#include "base/strings/string_piece.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/sequenced_task_runner.h"
Expand Down Expand Up @@ -267,7 +267,7 @@ bool ZipReader::OpenEntry() {
return true;
}

void ZipReader::Normalize(base::StringPiece16 in) {
void ZipReader::Normalize(std::u16string_view in) {
entry_.is_unsafe = true;

// Directory entries in ZIP have a path ending with "/".
Expand All @@ -281,15 +281,16 @@ void ZipReader::Normalize(base::StringPiece16 in) {

for (;;) {
// Consume initial path separators.
const base::StringPiece16::size_type i = in.find_first_not_of(u'/');
if (i == base::StringPiece16::npos)
const std::u16string_view::size_type i = in.find_first_not_of(u'/');
if (i == std::u16string_view::npos) {
break;
}

in.remove_prefix(i);
DCHECK(!in.empty());

// Isolate next path component.
const base::StringPiece16 part = in.substr(0, in.find_first_of(u'/'));
const std::u16string_view part = in.substr(0, in.find_first_of(u'/'));
DCHECK(!part.empty());

in.remove_prefix(part.size());
Expand Down
3 changes: 2 additions & 1 deletion deps/zlib/google/zip_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <limits>
#include <memory>
#include <string>
#include <string_view>

#include "base/files/file.h"
#include "base/files/file_path.h"
Expand Down Expand Up @@ -281,7 +282,7 @@ class ZipReader {

// Normalizes the given path passed as UTF-16 string piece. Sets entry_.path,
// entry_.is_directory and entry_.is_unsafe.
void Normalize(base::StringPiece16 in);
void Normalize(std::u16string_view in);

// Runs the ListenerCallback at a throttled rate.
void ReportProgress(ListenerCallback listener_callback, uint64_t bytes) const;
Expand Down
12 changes: 6 additions & 6 deletions deps/zlib/google/zip_reader_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <iterator>
#include <string>
#include <string_view>
#include <vector>

#include "base/check.h"
Expand All @@ -22,7 +23,6 @@
#include "base/i18n/time_formatting.h"
#include "base/path_service.h"
#include "base/run_loop.h"
#include "base/strings/string_piece.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/bind.h"
Expand Down Expand Up @@ -172,7 +172,7 @@ class ZipReaderTest : public PlatformTest {
}

static Paths GetPaths(const base::FilePath& zip_path,
base::StringPiece encoding = {}) {
std::string_view encoding = {}) {
Paths paths;

if (ZipReader reader; reader.Open(zip_path)) {
Expand Down Expand Up @@ -422,7 +422,7 @@ TEST_F(ZipReaderTest, EncryptedFile_WrongPassword) {
EXPECT_EQ("This is not encrypted.\n", contents);
}

for (const base::StringPiece path : {
for (const std::string_view path : {
"Encrypted AES-128.txt",
"Encrypted AES-192.txt",
"Encrypted AES-256.txt",
Expand Down Expand Up @@ -458,7 +458,7 @@ TEST_F(ZipReaderTest, EncryptedFile_RightPassword) {
}

// TODO(crbug.com/1296838) Support AES encryption.
for (const base::StringPiece path : {
for (const std::string_view path : {
"Encrypted AES-128.txt",
"Encrypted AES-192.txt",
"Encrypted AES-256.txt",
Expand Down Expand Up @@ -713,12 +713,12 @@ TEST_F(ZipReaderTest, ExtractCurrentEntryToString) {
if (i > 0) {
// Exact byte read limit: must pass.
EXPECT_TRUE(reader.ExtractCurrentEntryToString(i, &contents));
EXPECT_EQ(std::string(base::StringPiece("0123456", i)), contents);
EXPECT_EQ(std::string(std::string_view("0123456", i)), contents);
}

// More than necessary byte read limit: must pass.
EXPECT_TRUE(reader.ExtractCurrentEntryToString(&contents));
EXPECT_EQ(std::string(base::StringPiece("0123456", i)), contents);
EXPECT_EQ(std::string(std::string_view("0123456", i)), contents);
}
reader.Close();
}
Expand Down
6 changes: 4 additions & 2 deletions deps/zlib/google/zip_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "third_party/zlib/google/zip.h"

#include <stddef.h>
#include <stdint.h>

#include <iomanip>
#include <limits>
#include <string>
#include <string_view>
#include <unordered_map>
#include <unordered_set>
#include <vector>
Expand All @@ -29,7 +32,6 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
#include "third_party/zlib/google/zip.h"
#include "third_party/zlib/google/zip_internal.h"
#include "third_party/zlib/google/zip_reader.h"

Expand Down Expand Up @@ -1290,7 +1292,7 @@ TEST_F(ZipTest, Compressed) {
EXPECT_TRUE(base::CreateDirectory(src_dir));

// Create some dummy source files.
for (const base::StringPiece s : {"foo", "bar.txt", ".hidden"}) {
for (const std::string_view s : {"foo", "bar.txt", ".hidden"}) {
base::File f(src_dir.AppendASCII(s),
base::File::FLAG_CREATE | base::File::FLAG_WRITE);
ASSERT_TRUE(f.SetLength(5000));
Expand Down
2 changes: 1 addition & 1 deletion src/zlib_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
// Refer to tools/dep_updaters/update-zlib.sh
#ifndef SRC_ZLIB_VERSION_H_
#define SRC_ZLIB_VERSION_H_
#define ZLIB_VERSION "1.3.0.1-motley-209717d"
#define ZLIB_VERSION "1.3.0.1-motley-887bb57"
#endif // SRC_ZLIB_VERSION_H_

0 comments on commit a439535

Please sign in to comment.