Determine which IFC schema a STEP buffer declares (issue #3278).
The FILE_SCHEMA declaration is authoritative and is read from the
already-parsed IfcSourceHeader; free text elsewhere in the header is
not. That distinction is the whole point. FILE_DESCRIPTION and FILE_NAME
carry author, organisation, preprocessor and originating-system strings, and
exporters routinely stamp a schema token into their product name ("SomeApp
IFC4 Exporter") — which a raw substring scan of the header bytes cannot tell
apart from a declaration. Reading the record also reaches declarations that
sit past the first 2 KB: ISO 10303-21 puts FILE_SCHEMAafterFILE_NAME,
and a long author or organisation list pushes it out of a small fixed window.
Free on the hot path: parseSourceHeader already runs on every parse,
so nothing extra is scanned. The raw decode below now happens only for a file
that declares no schema at all.
When no FILE_SCHEMA identifier resolves, fall back to the historical raw
scan of the first 2000 bytes rather than refusing, so every file that
resolves today keeps resolving the same way. Being loose, that scan can match
ifc4 inside a GUID when there is no declaration at all; the Rust detector
does the same, and a shared vector pins it (#7740).
Determine which IFC schema a STEP buffer declares (issue #3278).
The
FILE_SCHEMAdeclaration is authoritative and is read from the already-parsed IfcSourceHeader; free text elsewhere in the header is not. That distinction is the whole point.FILE_DESCRIPTIONandFILE_NAMEcarry author, organisation, preprocessor and originating-system strings, and exporters routinely stamp a schema token into their product name ("SomeApp IFC4 Exporter") — which a raw substring scan of the header bytes cannot tell apart from a declaration. Reading the record also reaches declarations that sit past the first 2 KB: ISO 10303-21 putsFILE_SCHEMAafterFILE_NAME, and a long author or organisation list pushes it out of a small fixed window.Free on the hot path: parseSourceHeader already runs on every parse, so nothing extra is scanned. The raw decode below now happens only for a file that declares no schema at all.
When no
FILE_SCHEMAidentifier resolves, fall back to the historical raw scan of the first 2000 bytes rather than refusing, so every file that resolves today keeps resolving the same way. Being loose, that scan can matchifc4inside a GUID when there is no declaration at all; the Rust detector does the same, and a shared vector pins it (#7740).