123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- diff --git a/third_party/zxcvbn-cpp/data-scripts/build_frequency_lists.py b/third_party/zxcvbn-cpp/data-scripts/build_frequency_lists.py
- index d5504e0..9be1391 100755
- --- a/third_party/zxcvbn-cpp/data-scripts/build_frequency_lists.py
- +++ b/third_party/zxcvbn-cpp/data-scripts/build_frequency_lists.py
- @@ -122,8 +122,7 @@ def to_kv(lst, lst_name):
- val = '"%s".split(",")' % ','.join(lst)
- return '%s: %s' % (lst_name, val)
-
- -def output_coffee(args, script_name, freq_lists):
- - (output_file,) = args
- +def output_coffee(output_file, script_name, freq_lists):
- with codecs.open(output_file, 'w', 'utf8') as f:
- f.write('# generated by %s\n' % script_name)
- f.write('frequency_lists = \n ')
- @@ -286,6 +285,14 @@ def output_inc_js(output_file_js, script_name, freq_lists):
- f.write(',\n '.join(lines))
- f.write('}')
-
- +# Outputs the processed text files as text files again
- +def output_txt(output_txt, script_name, freq_lists):
- + for name, lst in freq_lists.items():
- + with codecs.open(output_txt.replace('.txt', name + '.txt'), 'w',
- + 'utf8') as f:
- + for word in lst:
- + f.write(word + '\n')
- +
- def main():
- if len(sys.argv) != 3:
- print(usage())
- @@ -301,6 +308,8 @@ def main():
- output_fn = output_hpp
- elif output_file_lower.endswith(".inc.js"):
- output_fn = output_inc_js
- + elif output_file_lower.endswith(".txt"):
- + output_fn = output_txt
- else:
- output_fn = output_coffee
-
- diff --git a/third_party/zxcvbn-cpp/native-src/zxcvbn/frequency_lists.cpp b/third_party/zxcvbn-cpp/native-src/zxcvbn/frequency_lists.cpp
- index 4e4b727..a7adbe9 100644
- --- a/third_party/zxcvbn-cpp/native-src/zxcvbn/frequency_lists.cpp
- +++ b/third_party/zxcvbn-cpp/native-src/zxcvbn/frequency_lists.cpp
- @@ -1,11 +1,26 @@
- #include <zxcvbn/frequency_lists.hpp>
-
- -#include <zxcvbn/_frequency_lists.hpp>
- -
- #include <unordered_map>
- +#include <utility>
- +
- +#include "base/no_destructor.h"
-
- namespace zxcvbn {
-
- +namespace {
- +
- +std::unordered_map<DictionaryTag, RankedDict>& ranked_dicts() {
- + static base::NoDestructor<std::unordered_map<DictionaryTag, RankedDict>>
- + ranked_dicts;
- + return *ranked_dicts;
- +}
- +
- +} // namespace
- +
- +void SetRankedDicts(std::unordered_map<DictionaryTag, RankedDict> dicts) {
- + ranked_dicts() = std::move(dicts);
- +}
- +
- RankedDicts convert_to_ranked_dicts(std::unordered_map<DictionaryTag, RankedDict> & ranked_dicts) {
- RankedDicts build;
-
- @@ -17,8 +32,7 @@ RankedDicts convert_to_ranked_dicts(std::unordered_map<DictionaryTag, RankedDict
- }
-
- RankedDicts default_ranked_dicts() {
- - return convert_to_ranked_dicts(_frequency_lists::get_default_ranked_dicts());
- + return convert_to_ranked_dicts(ranked_dicts());
- }
-
- -
- }
- diff --git a/third_party/zxcvbn-cpp/native-src/zxcvbn/frequency_lists.hpp b/third_party/zxcvbn-cpp/native-src/zxcvbn/frequency_lists.hpp
- index c75ea30..634ecb2 100644
- --- a/third_party/zxcvbn-cpp/native-src/zxcvbn/frequency_lists.hpp
- +++ b/third_party/zxcvbn-cpp/native-src/zxcvbn/frequency_lists.hpp
- @@ -2,7 +2,6 @@
- #define __ZXCVBN__FREQUENCY_LISTS_HPP
-
- #include <zxcvbn/frequency_lists_common.hpp>
- -#include <zxcvbn/_frequency_lists.hpp>
-
- #include <unordered_map>
-
- @@ -10,7 +9,15 @@
-
- namespace zxcvbn {
-
- -using DictionaryTag = _frequency_lists::DictionaryTag;
- +enum class DictionaryTag {
- + ENGLISH_WIKIPEDIA,
- + FEMALE_NAMES,
- + MALE_NAMES,
- + PASSWORDS,
- + SURNAMES,
- + US_TV_AND_FILM,
- + USER_INPUTS
- +};
-
- }
-
- @@ -29,6 +36,8 @@ namespace zxcvbn {
-
- using RankedDicts = std::unordered_map<DictionaryTag, const RankedDict &>;
-
- +void SetRankedDicts(std::unordered_map<DictionaryTag, RankedDict> dicts);
- +
- RankedDicts convert_to_ranked_dicts(std::unordered_map<DictionaryTag, RankedDict> & ranked_dicts);
- RankedDicts default_ranked_dicts();
-
|