Skip to content

IDS: XML entities are not decoded on load, and exported values are not escaped #817

Closed

Description

@helenkwok

IDSSpecifications.xmlParser is created with processEntities: false (IDSSpecifications/index.ts), so entities in an IDS file are kept as text. A specification named R&amp;D walls loads as R&amp;D walls, and a requirement value Smith &amp; Sons loads as Smith &amp; Sons, which never equals the model's Smith & Sons. Any IDS value containing &, <, > or quotes fails or is mismatched.

The export has the opposite problem: names, descriptions, instructions, the info block and facet values (exporters/parameter.ts) are written by string interpolation without escaping. Today that round-trips only because the values were never decoded. A value set in code that contains & or < produces invalid XML. For example a simple value Smith & Sons <Ltd> exports as <simpleValue>Smith & Sons <Ltd></simpleValue>, and re-loading reads <Ltd> as an element.

Reproduce

const ids = components.get(OBC.IDSSpecifications);
const [spec] = ids.load(`...<ids:specification name="R&amp;D walls" ifcVersion="IFC4">...`);
spec.name; // "R&amp;D walls", expected "R&D walls"

Suggested fix

Turn entity processing on (fast-xml-parser 5.7.2 decodes the predefined entities and applies its expansion limits by default), and escape text and attribute values on export. A PR with a test follows.

utils/xml.ts (XML.parser) and the BCF parser also use processEntities: false. I've left those alone here.

System info

main at 8479a7c, Node 24.14.0, macOS, yarn 3.2.1 (the repo's own setup).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions