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

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

Issue 1182183003: Move EndsWith to base namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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_ = EndsWith(file_name_in_zip, "/", false); 134 is_directory_ = base::EndsWith(file_name_in_zip, "/", false);
135 135
136 // Check the file name here for directory traversal issues. 136 // Check the file name here for directory traversal issues.
137 is_unsafe_ = file_path_.ReferencesParent(); 137 is_unsafe_ = file_path_.ReferencesParent();
138 138
139 // We also consider that the file name is unsafe, if it's invalid UTF-8. 139 // We also consider that the file name is unsafe, if it's invalid UTF-8.
140 base::string16 file_name_utf16; 140 base::string16 file_name_utf16;
141 if (!base::UTF8ToUTF16(file_name_in_zip.data(), file_name_in_zip.size(), 141 if (!base::UTF8ToUTF16(file_name_in_zip.data(), file_name_in_zip.size(),
142 &file_name_utf16)) { 142 &file_name_utf16)) {
143 is_unsafe_ = true; 143 is_unsafe_ = true;
144 } 144 }
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 } 532 }
533 533
534 bool FileWriterDelegate::WriteBytes(const char* data, int num_bytes) { 534 bool FileWriterDelegate::WriteBytes(const char* data, int num_bytes) {
535 int bytes_written = file_->WriteAtCurrentPos(data, num_bytes); 535 int bytes_written = file_->WriteAtCurrentPos(data, num_bytes);
536 if (bytes_written > 0) 536 if (bytes_written > 0)
537 file_length_ += bytes_written; 537 file_length_ += bytes_written;
538 return bytes_written == num_bytes; 538 return bytes_written == num_bytes;
539 } 539 }
540 540
541 } // namespace zip 541 } // 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