File: maithili_dsl/cli.py (translate_imports)
translate_imports() still uses blind str.replace() — the exact class of bug that was fixed in the transpiler for keywords (see v0.3.0 hardening). Two verified reproductions:
Substring corruption:
Input: उच्चगणित.कोष = १
Output: उच्चmath.कोष = १ # गणित matched inside उच्चगणित
Rewrites inside string literals:
Input: छपाउ("गणित.")
Output: छपाउ("math.") # user-visible output changed
Side effect: because "{module}." appearing anywhere (including strings/comments) adds the module to translated_modules, the import whitelist gets looser than intended.
Fix: reuse the word-boundary pattern machinery from transpile.py (_make_keyword_pattern) and run module translation on code regions only (after/with tokenization), not on the raw source. Track translated_modules from actual आयात statements rather than substring hits.
Tests: both repros above in tests/test_cli.py or tests/test_security.py, plus regression tests that legitimate आयात गणित + गणित.sqrt(...) still work.
File:
maithili_dsl/cli.py(translate_imports)translate_imports()still uses blindstr.replace()— the exact class of bug that was fixed in the transpiler for keywords (see v0.3.0 hardening). Two verified reproductions:Substring corruption:
Rewrites inside string literals:
Side effect: because
"{module}."appearing anywhere (including strings/comments) adds the module totranslated_modules, the import whitelist gets looser than intended.Fix: reuse the word-boundary pattern machinery from
transpile.py(_make_keyword_pattern) and run module translation on code regions only (after/with tokenization), not on the raw source. Tracktranslated_modulesfrom actualआयातstatements rather than substring hits.Tests: both repros above in
tests/test_cli.pyortests/test_security.py, plus regression tests that legitimateआयात गणित+गणित.sqrt(...)still work.