Ignore C0 and DEL while parsing DCS parameters #20919
<!-- AzurePipelinesStatusComment -->
<samp>
Azure Pipelines:<br>
There may be pipelines that require an authorized user to comment /azp run to run.<br>
</samp>
@microsoft-github-policy-service agree
The Linux C++ parser harness passed 4,422 stream checks under AddressSanitizer and UndefinedBehaviorSanitizer. These covered every ignorable C0 byte and DEL, character-by-character input, and every two-write split for the test sequences.
Excuse me, what? Can you explain what part of our project this is, or what bearing it has on our project?
Neat!
I'd like to discuss this "Linux" thing a little more.
The 4,422 checks came from a standalone harness the AI assistant created and ran while preparing this fix. It compiled Terminal’s stateMachine.cpp with Linux compatibility shims and exercised DCS sequences with different control bytes and write boundaries. That count was for the scratch harness, which I should have made clear in the PR description.
The Windows Actions run on my fork used Terminal’s own parser test suite. DcsParamIgnoresControlCharacters failed at the DCS identifier assertion with the original parser and passed with the patch. TAEF reported 760 passed, 0 failed, and 1 skipped. Windows test run
/azp run
<samp>
Azure Pipelines:<br>
Successfully started running 1 pipeline(s).<br>
1 pipeline(s) were filtered out due to trigger conditions.<br>
</samp>
Approved these changes.
lhecker
DawsonCodes
Summary of the Pull Request
Ignore C0 and DEL characters while parsing the parameters of a Device Control String (DCS).
References and Relevant Issues
Closes #20916
The
dcs paramstate ignores BEL (0x07) and DEL (0x7F) and continues collecting parameters. DEC ANSI parser state diagramDetailed Description of the Pull Request / Additional comments
_EventDcsParam()calls_ActionIgnore()for C0 and DEL, then falls through to a separate conditional chain that can dispatch the same byte as the final character. Changing the numeric/delimiter branch toelse ifkeeps the parser inDcsParamso the next byte can continue the same sequence.The regression test places BEL between two digits and DEL before the final character. It checks the dispatched identifier, both parameters, and the payload.
AI assistance was used to prepare the change, validate it locally, and draft this description.
Validation Steps Performed
InputEngineTest::RoundTripTest. Windows Actions runstateMachine.cppon Linux with compatibility shims. It passed 4,422 checks covering ignored control bytes in DCS parameters and sequences split across writes. Harness detailsPR Checklist