Expand description
Content preprocessing ported from guard_core/detection_engine/preprocessor.py.
Spec 4.0.2: the shared decode chain produces the processed view (null-byte removal, whitespace collapse, attack-preserving truncation) plus the decoded view handed to the URL-decoded scan pass, the signal-preserving raw view, and the short-base64 additive view.
Constants§
Functions§
- decode_
base64_ candidates decode_base64_candidates: candidate tokens are replaced by their decoded form when the printable/UTF-8 gates pass, with run-splitting and sub-floor reassembly fallbacks.- decode_
common_ encodings - Legacy entry kept for the ledger verification tooling.
- decode_
common_ encodings_ with_ budget decode_common_encodings: up to 16 fixed-point decode iterations, then a single SQL-comment strip. Returns(content, decode_budget_exhausted).- decode_
overlong_ utf8_ percent_ runs decode_overlong_utf8_percent_runs: percent-encoded byte runs that do not form valid UTF-8 are re-decoded leniently (overlong lead bytes).- normalize_
unicode - NFKC normalization + unicode lookalike replacement (fullwidth forms, zero-width characters, etc.).
- preprocess
preprocess: full processed view (legacy entry point).- preprocess_
signal_ preserving preprocess_signal_preserving: raw view (no decoding).- preprocess_
with_ decoded preprocess_with_decoded:(processed, decoded, decode_budget_exhausted).- short_
base64_ additive_ view preprocess_short_base64_additive_view: decoded fragments of short base64-looking tokens joined with newlines.- strip_
sql_ comments _strip_sql_comments: block comments becomebody(inner-word and/*!-guarded forms are kept); every--/#marker becomes one space.