OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/feedback/anonymizer_tool.h" | 5 #include "components/feedback/anonymizer_tool.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 // AnonymizerTool::AnonymizeCustomPattern for pattern anonymization examples. | 34 // AnonymizerTool::AnonymizeCustomPattern for pattern anonymization examples. |
35 // | 35 // |
36 // Useful regular expression syntax: | 36 // Useful regular expression syntax: |
37 // | 37 // |
38 // +? is a non-greedy (lazy) +. | 38 // +? is a non-greedy (lazy) +. |
39 // \b matches a word boundary. | 39 // \b matches a word boundary. |
40 // (?i) turns on case insensitivy for the remainder of the regex. | 40 // (?i) turns on case insensitivy for the remainder of the regex. |
41 // (?-s) turns off "dot matches newline" for the remainder of the regex. | 41 // (?-s) turns off "dot matches newline" for the remainder of the regex. |
42 // (?:regex) denotes non-capturing parentheses group. | 42 // (?:regex) denotes non-capturing parentheses group. |
43 const char* kCustomPatternsWithContext[] = { | 43 const char* kCustomPatternsWithContext[] = { |
44 "(\\bCell ID: ')([0-9a-fA-F]+)(')", // ModemManager | 44 "(\\bCell ID: ')([0-9a-fA-F]+)(')", // ModemManager |
45 "(\\bLocation area code: ')([0-9a-fA-F]+)(')", // ModemManager | 45 "(\\bLocation area code: ')([0-9a-fA-F]+)(')", // ModemManager |
46 "(?i-s)(\\bssid[= ]')(.+)(')", // wpa_supplicant | 46 "(?i-s)(\\bssid[= ]')(.+)(')", // wpa_supplicant |
47 "(?-s)(\\bSSID - hexdump\\(len=[0-9]+\\): )(.+)()", // wpa_supplicant | 47 "(?-s)(\\bSSID - hexdump\\(len=[0-9]+\\): )(.+)()", // wpa_supplicant |
48 "(?-s)(\\[SSID=)(.+?)(\\])", // shill | 48 "(?-s)(\\[SSID=)(.+?)(\\])", // shill |
| 49 "(?i-s)(serial\\s*number\\s*:\\s*)([0-9a-zA-Z\\-]+)()", // Serial numbers |
49 }; | 50 }; |
50 | 51 |
51 // Helper macro: Non capturing group | 52 // Helper macro: Non capturing group |
52 #define NCG(x) "(?:" x ")" | 53 #define NCG(x) "(?:" x ")" |
53 // Helper macro: Optional non capturing group | 54 // Helper macro: Optional non capturing group |
54 #define OPT_NCG(x) NCG(x) "?" | 55 #define OPT_NCG(x) NCG(x) "?" |
55 | 56 |
56 ////////////////////////////////////////////////////////////////////////// | 57 ////////////////////////////////////////////////////////////////////////// |
57 // Patterns for URLs, or better IRIs, based on RFC 3987 with an artificial | 58 // Patterns for URLs, or better IRIs, based on RFC 3987 with an artificial |
58 // limitation on the scheme to increase precision. Otherwise anything | 59 // limitation on the scheme to increase precision. Otherwise anything |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 } | 365 } |
365 | 366 |
366 skipped.AppendToString(&result); | 367 skipped.AppendToString(&result); |
367 result += replacement_id; | 368 result += replacement_id; |
368 } | 369 } |
369 text.AppendToString(&result); | 370 text.AppendToString(&result); |
370 return result; | 371 return result; |
371 } | 372 } |
372 | 373 |
373 } // namespace feedback | 374 } // namespace feedback |
OLD | NEW |