Avoid duplicate internal subsets.#6
Conversation
scymtym
left a comment
There was a problem hiding this comment.
I'm not sure I understand what is going on.
This change causes an error to be signaled from the parser before sax:start-internal-subset is called, but the sink, which must be a sink instance for the have-internal-subset call to work, does its own check:
(defmethod sax:start-internal-subset ((sink sink))
(when (have-internal-subset sink)
(error "duplicate internal subset"))
…)| (ensure-dtd) | ||
| (sax:start-internal-subset (handler *ctx*)) | ||
| ;; Avoid duplicate internal subsets. | ||
| (unless (ignore-errors (have-internal-subset (handler *ctx*))) |
There was a problem hiding this comment.
Why is the ignore-errors necessary? The only method on have-internal-subset is a slot reader, the slot has :initform nil and there doesn't seem to be a `slot-makunbound' call for the slot.
There was a problem hiding this comment.
Just running the tests, I see that cxml:sax-proxy does not inherit from cxml:sink, and so does not have an internal-subset slot at all, and rune-dom::dom-builder, while it does inherit from cxml:sink, overrides the definition of the slot and does not provide an initform. Of course there might be others.
|
The bug this pull request addresses only arises with XML documents that have both a DTD and an internal subset. The patch in 731dd98 solves the problem of getting the serializer to print definitions from DTDs as an internal subset by triggering the The problem is that a document could actually have both a DTD and an internal subset, in which case The simplest thing is to avoid calling |
I added this change to the previous pull request, but it didn't get merged, I assume because I added it late and it was overlooked. It fixes a bug introduced by the previous fix to DTD embedding, which can result in errors due to duplicate internal subsets and breaks ~60 tests in the SAX test suite (it does not affect Klacks).