A declared 16/32-bit encoding over BOM-less 8-bit bytes is rejected; a BOM followed by a declaration outside its family is rejected, reading the declaration through the BOM's own byte pattern; and an external entity whose text declaration names a higher XML version than the document is refused (errata E38). The eduni not-wf baseline is empty. Reader and decoder helpers split for the length caps. Closes #137
27 lines
1.1 KiB
Swift
27 lines
1.1 KiB
Swift
/// The end-tag scanner, split from the reader body to keep it under the
|
|
/// length caps. Behavior is part of EventReader proper.
|
|
extension PureXML.Parsing.EventReader {
|
|
typealias Event = PureXML.Parsing.Event
|
|
typealias ParseError = PureXML.Parsing.ParseError
|
|
mutating func scanEndTag() throws -> Event {
|
|
let mark = reader.mark
|
|
reader.consume("</")
|
|
let name = try scanName()
|
|
reader.skipSpace()
|
|
guard reader.consume(">") else {
|
|
throw ParseError.unterminatedTag(reader.mark)
|
|
}
|
|
guard let top = open.last else {
|
|
throw ParseError.unexpectedEndTag(name: name.description, mark)
|
|
}
|
|
// Tag matching is lexical (the qualified-name text must match); the
|
|
// open name additionally carries its resolved namespace URI.
|
|
guard top.description == name.description else {
|
|
throw ParseError.mismatchedEndTag(expected: top.description, found: name.description, mark)
|
|
}
|
|
open.removeLast()
|
|
namespaces.leaveElement()
|
|
return .endElement(name: top)
|
|
}
|
|
}
|