Make WordPress Core

Ticket #31647: 31647.diff

File 31647.diff, 2.4 KB (added by pento, 9 years ago)
  • data-scripts/build_frequency_lists.py

    diff --git a/data-scripts/build_frequency_lists.py b/data-scripts/build_frequency_lists.py
    index cd1d1d5..0e2a2f4 100755
    a b def filter_frequency_lists(freq_lists): 
    117117    return result
    118118
    119119def to_kv(lst, lst_name):
     120    lst = map(lambda x : codecs.encode(x, 'rot_13'), lst)
    120121    val = '"%s".split(",")' % ','.join(lst)
    121122    return '%s: %s' % (lst_name, val)
    122123
  • src/main.coffee

    diff --git a/src/main.coffee b/src/main.coffee
    index 79f125b..ddd3c41 100644
    a b feedback = require './feedback' 
    55
    66time = -> (new Date()).getTime()
    77
     8rot_13 = (str) ->
     9  str.replace /[a-zA-Z]/g, (c) ->
     10    String.fromCharCode (if ((if c <= "Z" then 90 else 122)) >= (c = c.charCodeAt(0) + 13) then c else c - 26)
     11
    812zxcvbn = (password, user_inputs = []) ->
    913  start = time()
    1014  # reset the user inputs matcher on a per-request basis to keep things stateless
    1115  sanitized_inputs = []
    1216  for arg in user_inputs
    1317    if typeof arg in ["string", "number", "boolean"]
    14       sanitized_inputs.push arg.toString().toLowerCase()
     18      sanitized_inputs.push rot_13(arg.toString().toLowerCase())
    1519  matching.set_user_input_dictionary sanitized_inputs
    1620  matches = matching.omnimatch password
    1721  result = scoring.most_guessable_match_sequence password, matches
  • src/matching.coffee

    diff --git a/src/matching.coffee b/src/matching.coffee
    index d85c145..cfb5a88 100644
    a b frequency_lists = require('./frequency_lists') 
    22adjacency_graphs = require('./adjacency_graphs')
    33scoring = require('./scoring')
    44
     5rot_13 = (str) ->
     6  str.replace /[a-zA-Z]/g, (c) ->
     7    String.fromCharCode (if ((if c <= "Z" then 90 else 122)) >= (c = c.charCodeAt(0) + 13) then c else c - 26)
     8
    59build_ranked_dict = (ordered_list) ->
    610  result = {}
    711  i = 1 # rank starts at 1, not 0
    matching = 
    103107    matches = []
    104108    len = password.length
    105109    password_lower = password.toLowerCase()
     110    password_lower = rot_13(password_lower)
    106111    for dictionary_name, ranked_dict of _ranked_dictionaries
    107112      for i in [0...len]
    108113        for j in [i...len]
    matching = 
    114119              i: i
    115120              j: j
    116121              token: password[i..j]
    117               matched_word: word
     122              matched_word: rot_13(word)
    118123              rank: rank
    119124              dictionary_name: dictionary_name
    120125              reversed: false