/ rules / D-SCHEMA-06.py
D-SCHEMA-06.py
 1  """
 2  Rule: D-SCHEMA-06 - disallowed characters
 3  Type: semantic | Output: binary
 4  Description: Reject on control or bidi override characters in text.
 5  Spec reference: 8.1.1
 6  """
 7  
 8  # TODO: Implement disallowed characters check
 9  # Input: NIP-35 event dict with tags field
10  # Output: {"passed": bool}
11  #
12  # Steps:
13  #   1. Extract text fields (title, summary) from entry
14  #   2. For each field, scan characters with unicodedata.category()
15  #   3. Check for control characters (Cc category except whitespace)
16  #   4. Check for bidi override chars (U+202A-U+202E, U+2066-U+2069)
17  #   5. Return {'passed': False} if disallowed chars found
18  #
19  # Edge cases:
20  #   - Legitimate whitespace (newline, tab)
21  #   - Zero-width chars
22  #   - Combining marks
23  #
24  # Dependencies: unicodedata (stdlib)
25  # Estimated complexity: Medium (25-35) lines
26  # Priority: High (security - UI spoofing prevention)
27  
28  from simple_types import BinaryRuleResult, Nip35Kind2003Event
29  
30  
31  def main(entry: Nip35Kind2003Event) -> BinaryRuleResult:
32      return {"passed": True}