Skip to content

Commit 3145e6b

Browse files
committed
updated with v10.0.0 of unicode.org confusables.txt file
1 parent 0b0d1b3 commit 3145e6b

File tree

9 files changed

+942
-463
lines changed

9 files changed

+942
-463
lines changed

generator/main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from output_char_codes import OutputCharCodes
44
from output_chars import OutputChars
55
from output_js import OutputJS
6+
from output_js_tests import OutputJSTests
67

78
TEMPLATES_DIR = 'generator/templates'
89
DATA_DIR = 'generator/source_data'
@@ -18,3 +19,4 @@
1819
OutputChars('raw_data', TEMPLATES_DIR).create(cm)
1920
OutputJS('homoglyph.js', 'javascript/src', TEMPLATES_DIR).create(cm, CHARS)
2021
OutputJS('index.js','node', TEMPLATES_DIR).create(cm, CHARS)
22+
OutputJSTests('DataTests.js','javascript/tests/js/tests', TEMPLATES_DIR).create(cm, CHARS)

generator/output_js_tests.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from output_builder import OutputBuilder
2+
3+
class OutputJSTests(OutputBuilder):
4+
def __init__(self, file_name, output_dir, template_dir):
5+
self.file_name = file_name
6+
OutputBuilder.__init__(self, output_dir, template_dir)
7+
8+
def create(self, char_manager, chars):
9+
check_statements = []
10+
for char in chars:
11+
char_homoglyphs = char_manager.get_set_for_char(char)
12+
char_homoglyphs_as_unicode = []
13+
for char_homoglyph in char_homoglyphs:
14+
char_homoglyphs_as_unicode.append('"\\u{' + '{:0>4}'.format(self._hex_code_for_char(char_homoglyph)) + '}"')
15+
16+
check_statements.append(' check("{}", [{}]);'.format(char, ' ,'.join(char_homoglyphs_as_unicode)))
17+
18+
text = self._get_template_text().replace('[[check_statements]]', '\n'.join(check_statements))
19+
20+
self._write_output(text)

generator/source_data/confusables.txt

Lines changed: 448 additions & 107 deletions
Large diffs are not rendered by default.

generator/templates/DataTests.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
describe("Homoglyph Search - Data Tests", function () {
2+
function check(targetChar, homoglyphs){
3+
describe("Homoglyphs of '" + targetChar + "'", function(){
4+
homoglyphs.forEach(function (c) {
5+
it("Checking '" + c + "'", function () {
6+
var textContainingHomoglyph = 'xx' + c + 'xx',
7+
targetWord = 'xx' + targetChar + 'xx';
8+
expect(search(textContainingHomoglyph, [targetWord])).toEqual([{match: textContainingHomoglyph, word: targetWord, index: 0}]);
9+
})
10+
});
11+
})
12+
}
13+
14+
[[check_statements]]
15+
16+
});

javascript/src/homoglyph.js

Lines changed: 61 additions & 61 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

javascript/tests/js/tests/DataTests.js

Lines changed: 62 additions & 62 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node/index.js

Lines changed: 61 additions & 61 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

raw_data/char_codes.txt

Lines changed: 135 additions & 86 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)