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

Side by Side Diff: components/autofill/core/browser/validation.cc

Issue 1907163003: Don't offer to save credit cards with an empty or 0 month. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 | « no previous file | components/autofill/core/browser/validation_unittest.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/autofill/core/browser/validation.h" 5 #include "components/autofill/core/browser/validation.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_piece.h" 10 #include "base/strings/string_piece.h"
(...skipping 22 matching lines...) Expand all
33 int cc_month; 33 int cc_month;
34 if (!base::StringToInt(month_cleaned, &cc_month)) 34 if (!base::StringToInt(month_cleaned, &cc_month))
35 return false; 35 return false;
36 36
37 return IsValidCreditCardExpirationDate(cc_year, cc_month, now); 37 return IsValidCreditCardExpirationDate(cc_year, cc_month, now);
38 } 38 }
39 39
40 bool IsValidCreditCardExpirationDate(int year, 40 bool IsValidCreditCardExpirationDate(int year,
41 int month, 41 int month,
42 const base::Time& now) { 42 const base::Time& now) {
43 if (month < 1 || month > 12)
44 return false;
45
43 base::Time::Exploded now_exploded; 46 base::Time::Exploded now_exploded;
44 now.LocalExplode(&now_exploded); 47 now.LocalExplode(&now_exploded);
45 48
46 if (year < now_exploded.year) 49 if (year < now_exploded.year)
47 return false; 50 return false;
48 51
49 if (year == now_exploded.year && month < now_exploded.month) 52 if (year == now_exploded.year && month < now_exploded.month)
50 return false; 53 return false;
51 54
52 return true; 55 return true;
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 number_string.begin() + 9), 204 number_string.begin() + 9),
202 &serial) 205 &serial)
203 || serial == 0) { 206 || serial == 0) {
204 return false; 207 return false;
205 } 208 }
206 209
207 return true; 210 return true;
208 } 211 }
209 212
210 } // namespace autofill 213 } // namespace autofill
OLDNEW
« no previous file with comments | « no previous file | components/autofill/core/browser/validation_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698