Skip to content

Add bidirectional-text QA with Trojan-source detection#319

Merged
JE-Chen merged 1 commit into
devfrom
feat/bidi-check-batch
Jun 22, 2026
Merged

Add bidirectional-text QA with Trojan-source detection#319
JE-Chen merged 1 commit into
devfrom
feat/bidi-check-batch

Conversation

@JE-Chen

@JE-Chen JE-Chen commented Jun 22, 2026

Copy link
Copy Markdown
Member

Summary

confusables catches lookalike characters, but invisible Unicode directional formatting (LRE/RLE/LRO/RLO/PDF, isolates LRI/RLI/FSI/PDI, marks LRM/RLM/ALM) can silently reorder how text renders — an RTL localisation-QA gap and the basis of the "Trojan Source" attack (CVE-2021-42574). This reports the bidi controls in a string, checks nesting balance, infers base direction, and flags Trojan-source-style formatting.

Layers

  • Headless core: je_auto_control/utils/bidi_check/bidi_check.pybidi_controls, has_bidi_controls, is_balanced, base_direction, strip_bidi_controls, is_trojan_source, detect_bidi_issues. Pure stdlib (unicodedata), no PySide6. Control code points are built with chr() so the source itself holds no bidi characters (avoids Bandit B613 on the detector).
  • Facade: re-exported (with is_balanced aliased to is_bidi_balanced) + __all__.
  • Executor: AC_bidi_check → report, AC_bidi_strip → {text}.
  • MCP: ac_bidi_check / ac_bidi_strip.
  • Script Builder: two CommandSpecs under Data.

Tests / docs

  • test/unit_test/headless/test_bidi_check_batch.py — 9 headless tests (control listing, balance incl. mismatched close, base direction, strip, Trojan-source flag + wiring + facade). Controls built via chr().
  • EN/Zh feature docs v111_features_doc.rst + toctrees; 3 README What's-new sections.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 51 complexity · 0 duplication

Metric Results
Complexity 51
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@JE-Chen JE-Chen merged commit 8e8f5d6 into dev Jun 22, 2026
16 checks passed
@JE-Chen JE-Chen deleted the feat/bidi-check-batch branch June 22, 2026 03:48
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant