PureXML/Sources/Parsing/UnparsedEntity.swift
Mihaela Mihaljevic 7f1aada240 feat(dtd): conditional sections, notations, NDATA, external parameter entities
Deepen DTD processing in the doctype scanner:

- Conditional sections are processed, not skipped: INCLUDE sections have
  their declarations scanned, IGNORE sections are discarded, the keyword
  may be a parameter-entity reference, and nested sections are handled.
- <!NOTATION> declarations are parsed and stored on DocumentType.
- Unparsed entities (<!ENTITY ... NDATA n>) are parsed and stored with
  their notation, distinct from general entities.
- External parameter entities are loaded through the injected resolver so
  their declarations expand; the default refusing resolver loads nothing,
  keeping XXE closed.
- NOTATION attributes are a distinct type, validated against the declared
  notations (value must be listed and the notation declared).

Tracking unparsed entities also lets ENTITY/ENTITIES attribute values be
validated against the declared NDATA entities, closing the gap left when
#73 could only check name syntax.

Closes #72
2026-06-08 14:39:42 +02:00

17 lines
684 B
Swift

public extension PureXML.Parsing {
/// An unparsed general entity: declared with an external identifier and an
/// `NDATA` notation (`<!ENTITY name SYSTEM "..." NDATA gif>`). Its content is
/// never parsed as XML; a processor hands it to the application by notation.
struct UnparsedEntity: Equatable, Sendable {
/// The entity's external identifier (its `SYSTEM`/`PUBLIC` location).
public var id: ExternalID
/// The name of the notation declared for the entity's data.
public var notation: String
public init(id: ExternalID, notation: String) {
self.id = id
self.notation = notation
}
}
}