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

Side by Side Diff: net/ftp/ftp_directory_listing_parser_windows.cc

Issue 3013029: Fix a bug with parsing ftp directory listing lines. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // LICENSE file.
4 4
5 #include "net/ftp/ftp_directory_listing_parser_windows.h" 5 #include "net/ftp/ftp_directory_listing_parser_windows.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "net/ftp/ftp_util.h" 10 #include "net/ftp/ftp_util.h"
(...skipping 30 matching lines...) Expand all
41 if (columns[1].length() != 7) 41 if (columns[1].length() != 7)
42 return false; 42 return false;
43 std::vector<string16> time_parts; 43 std::vector<string16> time_parts;
44 SplitString(columns[1].substr(0, 5), ':', &time_parts); 44 SplitString(columns[1].substr(0, 5), ':', &time_parts);
45 if (time_parts.size() != 2) 45 if (time_parts.size() != 2)
46 return false; 46 return false;
47 if (!StringToInt(time_parts[0], &time_exploded.hour)) 47 if (!StringToInt(time_parts[0], &time_exploded.hour))
48 return false; 48 return false;
49 if (!StringToInt(time_parts[1], &time_exploded.minute)) 49 if (!StringToInt(time_parts[1], &time_exploded.minute))
50 return false; 50 return false;
51 if (!time_exploded.HasValidValues())
52 return false;
51 string16 am_or_pm(columns[1].substr(5, 2)); 53 string16 am_or_pm(columns[1].substr(5, 2));
52 if (EqualsASCII(am_or_pm, "PM")) 54 if (EqualsASCII(am_or_pm, "PM")) {
53 time_exploded.hour += 12; 55 if (time_exploded.hour < 12)
54 else if (!EqualsASCII(am_or_pm, "AM")) 56 time_exploded.hour += 12;
57 } else if (EqualsASCII(am_or_pm, "AM")) {
58 if (time_exploded.hour == 12)
59 time_exploded.hour = 0;
60 } else {
55 return false; 61 return false;
62 }
56 63
57 // We don't know the time zone of the server, so just use local time. 64 // We don't know the time zone of the server, so just use local time.
58 *time = base::Time::FromLocalExploded(time_exploded); 65 *time = base::Time::FromLocalExploded(time_exploded);
59 return true; 66 return true;
60 } 67 }
61 68
62 } // namespace 69 } // namespace
63 70
64 namespace net { 71 namespace net {
65 72
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 return !entries_.empty(); 112 return !entries_.empty();
106 } 113 }
107 114
108 FtpDirectoryListingEntry FtpDirectoryListingParserWindows::PopEntry() { 115 FtpDirectoryListingEntry FtpDirectoryListingParserWindows::PopEntry() {
109 FtpDirectoryListingEntry entry = entries_.front(); 116 FtpDirectoryListingEntry entry = entries_.front();
110 entries_.pop(); 117 entries_.pop();
111 return entry; 118 return entry;
112 } 119 }
113 120
114 } // namespace net 121 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698