Mirrored from https://github.com/davoodmehraban89/Aram.git
Synced Dec 3, 22:00 UTC
fix(desktop): reject invisible and bidirectional text controls in drill-down
davoodmehraban89 committed
Oct 31, 2026 at 21:52 UTC
854be4b110004e1932ebdc14c0b81b37bf82810f
1 file changed
+11
-1
backend/src/aram_backend/desktop_five_statement_details.py
+11
-1
@@ -2,6 +2,7 @@
2
from __future__ import annotations
3
4
from dataclasses import dataclass
5
+import unicodedata
6
7
from aram_backend.coverage_preview import CoverageError
8
from aram_backend.desktop_five_statement_integrity import validate_desktop_pipeline_result
@@ -11,6 +12,15 @@ from aram_backend.reconciliation_review import _money
12
MAX_DETAIL_ROWS = 75_000
13
14
15
+def _unsafe_display_character(char: str) -> bool:
16
+ codepoint = ord(char)
17
+ category = unicodedata.category(char)
18
+ return (
19
+ category in {"Cc", "Cs"}
20
+ or (category == "Cf" and codepoint not in {0x200C, 0x200D})
21
+ )
22
+
23
+
24
@dataclass(frozen=True)
25
class PreviewDetail:
26
statement: str
@@ -36,7 +46,7 @@ class PreviewDetail:
46
def _text(value: object, label: str, *, blank_ok: bool = False) -> str:
47
if (not isinstance(value, str) or len(value) > 1024
48
or value != value.strip() or (not value and not blank_ok)
39
- or any(ord(char) < 32 or ord(char) == 127 for char in value)):
49
+ or any(_unsafe_display_character(char) for char in value)):
50
raise CoverageError("DESKTOP_DETAIL_" + label + "_INVALID")
51
return value
52