step-examples/12-1a-encoding/Le013.stp
Sources
- T010, T038/step-file-parser
- A009/lexer pitfall (analogue to SQL)
- R051/OCCT bug 25171
- G043/OCCT 4661dca, Mantis 25171
- N011/ISO 10303-21 Ed.3 §6.4.3.1
Description
ISO 10303-21 escapes a literal apostrophe inside a string by doubling it: `'It''s'` decodes to `It's`. State machines that do not treat the doubled quote as escape mistake mid-string `''` for end-of-string + start-of-next, leading to a misaligned token stream and (in worst cases) heap corruption when a later write uses the wrong length. Parity matters when an even number of consecutive apostrophes appears.
Reproducer recipe
`#1=PERSON('O''Brien','x');`; `'a''b'` decodes to `a'b`; `''''` decodes to two literal apostrophes; producer that builds strings via naive concatenation and forgets to double — `'O'Brien'`.
Expected kernel behavior
track parity of consecutive apostrophes; only an odd count terminates the string. Collapse `''` → `'` in canonical form during tokenisation. Tolerant readers may use look-ahead heuristics (peek for a comma or close paren) to recover from un-doubled apostrophes but must flag the result.
Notes
Synonyms: "doubled apostrophe in STEP string misread as terminator", "It''s parsed as two strings", "embedded quote breaks string", "apostrophe doubling not recognised", "single quote escape mishandled". Provenance tier: bytes-only — defect is context/metadata OCC does not read at BRep load; mutation-test verified oracle-invisible (2026-07-01).
Expected validation
occt=empty/empty gmsh=empty ifc=schema_n/a
Provenance tier
bytes-only — defect not fully embodied in fixture bytes.
Byte assertions
contains(b"O''Brien") or contains(b"a''b") or contains(b"''''")count(b"''") >= 3
Tier-3 assertions
shape_null == True
Live oracle output
No live oracle data — run _run_corpus to populate.
Fixture content
Show fixture bytes (with defect highlighting)
1ISO-10303-21; 2/* Le013: Apostrophe-doubling escape '' confused with string terminator; ISO 10303-21 §6.4.3.1: a literal apostrophe inside a string is escaped by doubling it â 'It''s' decodes to the 4-char string It's; defect 1: 'O''Brien' â parser must NOT split at the doubled quote; defect 2: '''' â four consecutive apostrophes encode two literal apostrophes; defect 3: 'a''b' â doubled apostrophe mid-string; a parser that treats '' as end-of-string + start-of-next desynchronizes the token stream; subsequent attributes shift by one position; downstream entity construction fails type-check or builds wrong sub-tree; receiver must track parity of consecutive apostrophes; only an odd count terminates the string; GEOMETRIC_CURVE_SET IS model entity â OCC yields empty */ 3HEADER; 4FILE_DESCRIPTION(('Le013'),'2;1'); 5FILE_NAME('Le013.stp','2026-06-17T00:00:00',(''),(''),'cad-research-suite','',''); 6FILE_SCHEMA(('AUTOMOTIVE_DESIGN { 1 0 10303 214 3 1 1 }')); 7ENDSEC; 8DATA; 9#1=CARTESIAN_POINT('',(0.0,0.0,0.0)); 10#2=GEOMETRIC_CURVE_SET('',(#1)); 11#8997=PERSON('O''Brien','x',''); 12#8998=PERSON('a''b','doubled-mid-string',''); 13#8999=PERSON('''''','four-consecutive-apostrophes',''); 14 15ENDSEC; 16END-ISO-10303-21;