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

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

Issue 109863003: Use StringPiece for UTF string conversions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « ppapi/proxy/pdf_resource_unittest.cc ('k') | ui/base/clipboard/clipboard_win.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/file_util.h" 7 #include "base/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 22 matching lines...) Expand all
33 33
34 // Directory entries in zip files end with "/". 34 // Directory entries in zip files end with "/".
35 is_directory_ = EndsWith(file_name_in_zip, "/", false); 35 is_directory_ = EndsWith(file_name_in_zip, "/", false);
36 36
37 // Check the file name here for directory traversal issues. In the name of 37 // Check the file name here for directory traversal issues. In the name of
38 // simplicity and security, we might reject a valid file name such as "a..b". 38 // simplicity and security, we might reject a valid file name such as "a..b".
39 is_unsafe_ = file_name_in_zip.find("..") != std::string::npos; 39 is_unsafe_ = file_name_in_zip.find("..") != std::string::npos;
40 40
41 // We also consider that the file name is unsafe, if it's invalid UTF-8. 41 // We also consider that the file name is unsafe, if it's invalid UTF-8.
42 base::string16 file_name_utf16; 42 base::string16 file_name_utf16;
43 if (!UTF8ToUTF16(file_name_in_zip.data(), file_name_in_zip.size(), 43 if (!UTF8ToUTF16(file_name_in_zip, &file_name_utf16)) {
44 &file_name_utf16)) {
45 is_unsafe_ = true; 44 is_unsafe_ = true;
46 } 45 }
47 46
48 // We also consider that the file name is unsafe, if it's absolute. 47 // We also consider that the file name is unsafe, if it's absolute.
49 // On Windows, IsAbsolute() returns false for paths starting with "/". 48 // On Windows, IsAbsolute() returns false for paths starting with "/".
50 if (file_path_.IsAbsolute() || StartsWithASCII(file_name_in_zip, "/", false)) 49 if (file_path_.IsAbsolute() || StartsWithASCII(file_name_in_zip, "/", false))
51 is_unsafe_ = true; 50 is_unsafe_ = true;
52 51
53 // Construct the last modified time. The timezone info is not present in 52 // Construct the last modified time. The timezone info is not present in
54 // zip files, so we construct the time as local time. 53 // zip files, so we construct the time as local time.
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 } 300 }
302 301
303 void ZipReader::Reset() { 302 void ZipReader::Reset() {
304 zip_file_ = NULL; 303 zip_file_ = NULL;
305 num_entries_ = 0; 304 num_entries_ = 0;
306 reached_end_ = false; 305 reached_end_ = false;
307 current_entry_info_.reset(); 306 current_entry_info_.reset();
308 } 307 }
309 308
310 } // namespace zip 309 } // namespace zip
OLDNEW
« no previous file with comments | « ppapi/proxy/pdf_resource_unittest.cc ('k') | ui/base/clipboard/clipboard_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698