fix: reject unsupported SKK expressions
This commit is contained in:
@@ -32,9 +32,9 @@ the normal build image.
|
|||||||
|
|
||||||
`skk2ktrans` accepts one or more EUC-JP SKK files (or standard input), writes
|
`skk2ktrans` accepts one or more EUC-JP SKK files (or standard input), writes
|
||||||
UTF-8 tab-separated rows, and merges input in command-line and source order.
|
UTF-8 tab-separated rows, and merges input in command-line and source order.
|
||||||
It strips annotations, deduplicates candidates, and omits expressions and
|
It strips annotations, deduplicates candidates, and omits candidates containing
|
||||||
candidates containing whitespace. Escaped candidate delimiters are rejected;
|
whitespace. Rows containing expressions or escaped candidate delimiters are
|
||||||
rewrite or omit those entries before import.
|
rejected; rewrite or omit those rows before import.
|
||||||
|
|
||||||
`verifymap.py` checks UTF-8, row structure, unique keys, 64-rune keys and
|
`verifymap.py` checks UTF-8, row structure, unique keys, 64-rune keys and
|
||||||
values, canonical candidate spacing, and duplicate dictionary candidates.
|
values, canonical candidate spacing, and duplicate dictionary candidates.
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ function add(k, v, id) {
|
|||||||
fail("invalid row")
|
fail("invalid row")
|
||||||
if(field ~ /\\/)
|
if(field ~ /\\/)
|
||||||
fail("escaped candidates are unsupported")
|
fail("escaped candidates are unsupported")
|
||||||
|
if(field ~ /\/[([#]/)
|
||||||
|
fail("expression candidates are unsupported")
|
||||||
n = split(substr(field, 2, length(field)-2), value, "/")
|
n = split(substr(field, 2, length(field)-2), value, "/")
|
||||||
for(i = 1; i <= n; i++)
|
for(i = 1; i <= n; i++)
|
||||||
add(key, value[i])
|
add(key, value[i])
|
||||||
|
|||||||
@@ -3,4 +3,4 @@
|
|||||||
えがお /笑顔;face/
|
えがお /笑顔;face/
|
||||||
かんじ /感じ/漢字;duplicate/
|
かんじ /感じ/漢字;duplicate/
|
||||||
きごう /記号;symbol/普通/
|
きごう /記号;symbol/普通/
|
||||||
むこう /候補 with space/(concat "式" "候補")/[無効]/#0/
|
むこう /候補 with space/
|
||||||
|
|||||||
@@ -36,6 +36,13 @@ class Skk2KtransTest(unittest.TestCase):
|
|||||||
self.assertNotEqual(result.returncode, 0)
|
self.assertNotEqual(result.returncode, 0)
|
||||||
self.assertIn(b"escaped candidates are unsupported", result.stderr)
|
self.assertIn(b"escaped candidates are unsupported", result.stderr)
|
||||||
|
|
||||||
|
def test_expression_candidate_is_rejected(self):
|
||||||
|
source = b'key /(concat "a/b")/literal/\n'
|
||||||
|
result = subprocess.run(
|
||||||
|
[CONVERTER], input=source, capture_output=True, check=False)
|
||||||
|
self.assertNotEqual(result.returncode, 0)
|
||||||
|
self.assertIn(b"expression candidates are unsupported", result.stderr)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|||||||
Reference in New Issue
Block a user