OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/password_manager/core/browser/import/csv_reader.h" | 5 #include "components/password_manager/core/browser/import/csv_reader.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "third_party/re2/re2/re2.h" | 9 #include "third_party/re2/src/re2/re2.h" |
10 | 10 |
11 namespace { | 11 namespace { |
12 | 12 |
13 // Regular expression that matches and captures the first row in CSV formatted | 13 // Regular expression that matches and captures the first row in CSV formatted |
14 // data (i.e., until the first newline that is not enclosed in double quotes). | 14 // data (i.e., until the first newline that is not enclosed in double quotes). |
15 // Will throw away the potential trailing EOL character (which is expected to | 15 // Will throw away the potential trailing EOL character (which is expected to |
16 // have already been normalized to a single '\n'). | 16 // have already been normalized to a single '\n'). |
17 const char kFirstRowRE[] = | 17 const char kFirstRowRE[] = |
18 // Match and capture sequences of 1.) arbitrary characters inside correctly | 18 // Match and capture sequences of 1.) arbitrary characters inside correctly |
19 // matched double-quotes, or 2.) characters other than the double quote and | 19 // matched double-quotes, or 2.) characters other than the double quote and |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 records->resize(records->size() + 1); | 121 records->resize(records->size() + 1); |
122 for (size_t i = 0; i < column_names->size() && i < fields.size(); ++i) { | 122 for (size_t i = 0; i < column_names->size() && i < fields.size(); ++i) { |
123 records->back()[(*column_names)[i]].swap(fields[i]); | 123 records->back()[(*column_names)[i]].swap(fields[i]); |
124 } | 124 } |
125 } | 125 } |
126 | 126 |
127 return true; | 127 return true; |
128 } | 128 } |
129 | 129 |
130 } // namespace password_manager | 130 } // namespace password_manager |
OLD | NEW |