Skip to content

Commit b114ec5

Browse files
committed
docs(P-030): escape BLNS payloads for Own string syntax in the sketch
Codex review on the consolidated PR: entries containing quotes or backslashes injected raw into the f-string would terminate the Own string literal early (counted as an 'honest rejection') or be decoded into different text, silently skipping exactly the corpus rows the pack is meant to exercise. Escape \\ and " before embedding, and note the complementary raw-lexer path that still exercises the unescaped entries.
1 parent a5c0c97 commit b114ec5

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

‎docs/proposals/P-030-naughty-strings-testing.md‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,13 @@ def run() -> int:
152152
# resource emit_*/kind members (a `let` rhs never takes a string),
153153
# so a benign entry parses cleanly and only the naughty content is
154154
# under test — the wrapper follows the run_tests.py PRELUDE shape.
155-
src = f'module M\nresource R {{ acquire a release r emit_type "{naughty}" }}\n'
155+
# Escape for Own string syntax first (the lexer decodes \\ and \")
156+
# so entries containing quotes/backslashes reach the parser as
157+
# themselves instead of terminating the literal early or being
158+
# decoded into different text — otherwise those exact corpus rows
159+
# would be silently skipped as "honest rejections".
160+
payload = naughty.replace("\\", "\\\\").replace('"', '\\"')
161+
src = f'module M\nresource R {{ acquire a release r emit_type "{payload}" }}\n'
156162
try:
157163
parse(src)
158164
except (ParseError, LexError):
@@ -164,6 +170,12 @@ def run() -> int:
164170
return 1 if fails else 0
165171
```
166172

173+
Two complementary paths per entry: the *escaped* embedding above proves the
174+
parser/analyzer path survives the payload as data; Layer 1 additionally feeds
175+
the **raw, unescaped** entry straight to `ownlang.lexer` (no wrapper), where
176+
`LexError` is a legal outcome — that path exercises exactly the quote/escape/
177+
control-character entries the escaped wrapper neutralizes.
178+
167179
Serialization side follows the same shape against `diag_sarif.py` /
168180
`cfg_json.py`, asserting `json.loads(...)` / a SARIF-shape check succeeds.
169181

0 commit comments

Comments
 (0)