Repository navigation
Hostile X12 input can no longer forge acknowledgement segments, inject script into the HTML report, or leak data values into logs. Install with pip install pyx12==4.1.0. Same code as 4.1.0rc1. Three caller-visible changes are listed under Breaking changes; read those before upgrading a production worker.
Breaking changes
-
X12Writer.Writenow raisesEngineErrorwhen an element value contains one of the writer's own delimiters (segment, element, sub-element or repetition separator). Previously the value was written as-is and produced corrupt X12. Affects callers that build segments with one set of delimiters and write with another, includingxmlx12_simpleand the examples. (#208) -
Reading a file whose segment has no terminator within 1 MiB now raises
X12Errorfromx12n_document(and the CLI scripts) instead of silently stopping at that segment. (#211) -
Log records on the
pyx12logger no longer include the error message or the offending data value; each is nowLine:N LEVEL:code refdes. Opt back in withparam.set("log_data_values", True),err_handler(log_data_values=True)orx12valid --log-data-values. Anything parsing pyx12 log lines sees the new shape. (#214)
Acknowledgement output changes
- Values copied from the input into a 997/999 ack (IK4-04 / AK4-04, IK3-01 / AK3-01, envelope ids) have
~ * : ^, control characters and non-ASCII replaced with?; IK4-04 / AK4-04 are capped at 99 characters. Previously a hostile value could forge ack segments. (#208)
Fixes
pyx12.errh_xml.err_handler()with no output path now deletes its temp report when the handler is collected or the process exits, and the no-argument form works again (it opened the file in binary mode and raisedTypeErroron first write). (#215)- A single segment longer than about 8 KB no longer silently ends the file; every following segment is read. (#211)
- x12xml output replaces control characters in data with
?so the document is always well-formed XML. (#211) - The HTML error report escapes error text and segment ids, so a hostile data value or segment id can no longer inject markup or script into the report. (#209)
Deprecated
pyx12.errh_xmlwarns on import and will be removed in 5.0. Usepyx12.errh_jsonor thefd_jsonoutput ofx12n_document. (#215)
Project
- CI and release workflows pin every GitHub Action to a commit SHA, run with a read-only token, and get weekly Dependabot bump PRs. (#210)
Full changelog: v4.0.1...v4.1.0