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

Side by Side Diff: third_party/zlib/google/zip_reader.cc

Issue 1233043003: Remove some legacy versions of StartsWith and EndsWith. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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 unified diff | Download patch
« no previous file with comments | « remoting/host/remoting_me2me_host.cc ('k') | tools/gn/ninja_binary_target_writer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "third_party/zlib/google/zip_reader.h" 5 #include "third_party/zlib/google/zip_reader.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file.h" 8 #include "base/files/file.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 // TODO(satorux): The implementation assumes that file names in zip files 124 // TODO(satorux): The implementation assumes that file names in zip files
125 // are encoded in UTF-8. This is true for zip files created by Zip() 125 // are encoded in UTF-8. This is true for zip files created by Zip()
126 // function in zip.h, but not true for user-supplied random zip files. 126 // function in zip.h, but not true for user-supplied random zip files.
127 ZipReader::EntryInfo::EntryInfo(const std::string& file_name_in_zip, 127 ZipReader::EntryInfo::EntryInfo(const std::string& file_name_in_zip,
128 const unz_file_info& raw_file_info) 128 const unz_file_info& raw_file_info)
129 : file_path_(base::FilePath::FromUTF8Unsafe(file_name_in_zip)), 129 : file_path_(base::FilePath::FromUTF8Unsafe(file_name_in_zip)),
130 is_directory_(false) { 130 is_directory_(false) {
131 original_size_ = raw_file_info.uncompressed_size; 131 original_size_ = raw_file_info.uncompressed_size;
132 132
133 // Directory entries in zip files end with "/". 133 // Directory entries in zip files end with "/".
134 is_directory_ = base::EndsWith(file_name_in_zip, "/", false); 134 is_directory_ = base::EndsWith(file_name_in_zip, "/",
135 base::CompareCase::INSENSITIVE_ASCII);
135 136
136 // Check the file name here for directory traversal issues. 137 // Check the file name here for directory traversal issues.
137 is_unsafe_ = file_path_.ReferencesParent(); 138 is_unsafe_ = file_path_.ReferencesParent();
138 139
139 // We also consider that the file name is unsafe, if it's invalid UTF-8. 140 // We also consider that the file name is unsafe, if it's invalid UTF-8.
140 base::string16 file_name_utf16; 141 base::string16 file_name_utf16;
141 if (!base::UTF8ToUTF16(file_name_in_zip.data(), file_name_in_zip.size(), 142 if (!base::UTF8ToUTF16(file_name_in_zip.data(), file_name_in_zip.size(),
142 &file_name_utf16)) { 143 &file_name_utf16)) {
143 is_unsafe_ = true; 144 is_unsafe_ = true;
144 } 145 }
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 } 533 }
533 534
534 bool FileWriterDelegate::WriteBytes(const char* data, int num_bytes) { 535 bool FileWriterDelegate::WriteBytes(const char* data, int num_bytes) {
535 int bytes_written = file_->WriteAtCurrentPos(data, num_bytes); 536 int bytes_written = file_->WriteAtCurrentPos(data, num_bytes);
536 if (bytes_written > 0) 537 if (bytes_written > 0)
537 file_length_ += bytes_written; 538 file_length_ += bytes_written;
538 return bytes_written == num_bytes; 539 return bytes_written == num_bytes;
539 } 540 }
540 541
541 } // namespace zip 542 } // namespace zip
OLDNEW
« no previous file with comments | « remoting/host/remoting_me2me_host.cc ('k') | tools/gn/ninja_binary_target_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698