Skip to content

Problem with XML content requirements and external entities: make MathML and SVG1.1 invalid #1338

Closed

Description

@iherman

The current text on XML conformance says that an XML-based media MUST meet:

...
External identifiers MUST NOT appear in the document type declaration [XML]
...

This constraint apply regardless of whether the given Publication Resource is a Core Media Type Resource or a Foreign Resource.

However, that creates problems with SVG 1.1. The conformance rules of SVG1.1 require the presence of:

<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" SYSTEM "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

The DTD itself, as described in the relevant appendix, is making a heavy use of external entities (via its usage of DTD Modularization). As a consequence, per the current document, no conform SVG 1.1 file is valid for EPUB 3.3.

Although the upcoming SVG 2 removed this requirement, there are lots of perfectly valid SVG 1.1 out there (SVG 2 is not yet a Recommendation, b.t.w., only a CR). Most notably, Adobe Illustrator generates SVG 1.1 files with those DTD-s in them.

A similar problem may occur with MathML 3, whose official DTD relies on the same approach (although MathML is more permissive and it does not require the usage of that DTD).

This problem was originally raised in w3c/epubcheck#1114.

Activity

  1. iherman commented on Oct 9, 2020

    @iherman
    MemberAuthor
  2. murata2makoto commented on Oct 10, 2020

    @murata2makoto
    Contributor

    @iherman

    The conformance rules of SVG1.1 require the presence of:

    No, it does not. The rules automatically add the DTD before validation.

    The DTD itself, as described in the relevant appendix, is making a heavy use of external entities (via its usage of DTD Modularization). As a consequence, per the current document, no conform SVG 1.1 file is valid for EPUB 3.3.

    The DTD heavily uses external parameter entities, which never occur in documents. But if memory is correct, it does not define any parsed entities.

  3. iherman commented on Oct 10, 2020

    @iherman
    MemberAuthor

    @murata2makoto

    @iherman

    The conformance rules of SVG1.1 require the presence of:

    No, it does not. The rules automatically add the DTD before validation.

    Checking it again, I stand corrected:-) The validity process requires the presence or the addition of the DTD. So my sentence:

    per the current document, no conform SVG 1.1 file is valid for EPUB 3.3.

    should rather say:

    per the current documents, conform SVG 1.1. files may not be valid for EPUB 3.3

    But, taking into account that tools produce SVG files with the DTD, and they have the perfect right to do so, the problem is not less severe for us. (I have just ran into a different application, called draw.io, that can produce nice diagrams in SVG and adds the DTD.)

    The DTD itself, as described in the relevant appendix, is making a heavy use of external entities (via its usage of DTD Modularization). As a consequence, per the current document, no conform SVG 1.1 file is valid for EPUB 3.3.

    The DTD heavily uses external parameter entities, which never occur in documents. But if memory is correct, it does not define any parsed entities.

    I believe you are right. But the presence of the external parameter entities in the DTD is enough to raise a red flag for EPUB.

  4. murata2makoto commented on Oct 10, 2020

    @murata2makoto
    Contributor

    @iherman

    But the presence of the external parameter entities in the DTD is enough to raise a red flag for EPUB.

    I do not understand. Since we do not allow external DTD subsets, external parameter entities are never encountered.

    I think that you would like to use the output of SVG software that always embed references to the DTD at the W3C web site. But such references have caused troubles to the W3C web site in the past.

  5. iherman commented on Oct 10, 2020

    @iherman
    MemberAuthor

    I think that you would like to use the output of SVG software that always embed references to the DTD at the W3C web site.

    Indeed. Such software implementations are correct in doing so, they exist, and our users may want to use them. Adobe Illustrator is probably the most prominent, and certainly very important example. I do not think we can expect, say, Adobe Illustrator users to manually edit their generated SVG files by removing that DTD reference.

    I.e., this is a very practical deployment issue.

    But such references have caused troubles to the W3C web site in the past.

    I do not know about the past, but the troubles are not in the present. My original issue came from the fact that most of the logos used in the W3C publications (e.g., all recommendations) in the past 3-4 years (at least) use SVG files that have those DTD-s, and all the Web Browsers accept those without further ado. Converting them into valid EPUB is not possibly without manually modifying the SVG files.

    I suspect that this issue never came up in EPUB land so far because Reading Systems tacitly accepted such SVG files (as the core Web engines accepted them). What brought it to the fore is the much stricter newer version of epubcheck that rejects those files. (This started the whole discussion in w3c/epubcheck#1114 after all...)

    I cc @rdeltour explicitly here, to call on the epubcheck implementers to give their opinion.

  6. murata2makoto commented on Oct 10, 2020

    @murata2makoto
    Contributor

    @iherman

    I still do not think that this is a problem. Yes, human users or software always have to remove external DTD subsets, if any. IDPF prohibited them, since parsing documents containing external DTD subsets has caused unnecessarily network access.

  7. mattgarrish commented on Oct 10, 2020

    @mattgarrish
    Member

    Yes, human users or software always have to remove external DTD subsets, if any.

    But why are we putting this requirement on authors and not reading systems? It's a reading system optimization pushed onto authors to carry out when a developer could suppress any resolution of DTD references. Isn't that pretty standard anyway, as it's been a while since I processed XML documents but W3C used to blacklist you if you tried to continuously resolve their DTDs.

    (And just for the record, I don't see that this affects MathML. MathML can only be embedded in HTML so can't have its own DTD declaration.)

  8. iherman commented on Oct 10, 2020

    @iherman
    MemberAuthor

    @iherman

    I still do not think that this is a problem. Yes, human users or software always have to remove external DTD subsets, if any. IDPF prohibited them, since parsing documents containing external DTD subsets has caused unnecessarily network access.

    Well, this is where we disagree. I believe it is a problem that one of the official content format has an unnecessary restriction compared to its official definition.

    But, actually, I do not understand your note, @murata2makoto. In your comment in w3c/epubcheck#1114 (comment) you seem to say that there is no such problem, that content with such DTD is o.k., and the bug is by epubcheck. In which case I believe we have to add some explanation in the spec.

  9. murata2makoto commented on Oct 12, 2020

    @murata2makoto
    Contributor

    @mattgarrish

    But why are we putting this requirement on authors and not reading systems? It's a reading system optimization pushed onto authors to carry out when a developer could suppress any resolution of DTD references. Isn't that pretty standard anyway, as it's been a while since I processed XML documents but W3C used to blacklist you if you tried to continuously resolve their DTDs.

    I might have agreed if this proposal was made when EPUB 3.0 was being designed. But the charter for EPUB 3.3 does not allow any changes that might destroy existing reading systems. If this DOCTYPE statement occurs in an SVG document, some existing EPUB 3 reading systems might try to fetch an external DTD subset. This causes network access, which is slow or unavailable.

  10. murata2makoto commented on Oct 12, 2020

    @murata2makoto
    Contributor

    @iherman

    In your comment in w3c/epubcheck#1114 (comment) you seem to say that there is no such problem, that content with such DTD is o.k., and the bug is by epubcheck. In which case I believe we have to add some explanation in the spec.

    My comment might not be clear. But I'm saying that the DOCTYPE statement in SVG must not be allowed by EPUB 3.3.

  11. mattgarrish commented on Oct 12, 2020

    @mattgarrish
    Member

    If this DOCTYPE statement occurs in an SVG document, some existing EPUB 3 reading systems might try to fetch an external DTD subset.

    But the only thing that stops this from happening now is the idea that only perfectly valid publications are ever loaded into reading systems. That seems unlikely given that there are often ways to side-load content.

    I agree we shouldn't cause backwards incompatibilities, but It would be interesting to survey whether moving the requirement to reading systems actually changes the way any have been implemented.

  12. iherman commented on Oct 12, 2020

    @iherman
    MemberAuthor

    @murata2makoto the backward compatibility issue is something we should check. You say:

    If this DOCTYPE statement occurs in an SVG document, some existing EPUB 3 reading systems might try to fetch an external DTD subset. This causes network access, which is slow or unavailable.

    and I am not sure such reading system actually exist. What I would think is that reading systems, so far, did not care about the DTD-s (surely all RS-s that relied on one of the web rendering engines) and this whole issue came to the fore because epubcheck reports this issue although it did not care about it before. In other words, I would expect there were a number of, technically, invalid EPUB content in circulation that were never flagged as such and that become invalid now.

    In other words, it may well be that the practical deployment of EPUB content as well as RS-s were actually both ignoring a constraint in the document...

  13. murata2makoto commented on Oct 12, 2020

    @murata2makoto
    Contributor

    @iherman

    I am not sure such reading system actually exist.

    It may well exist. If my memory is correct, a key member of IDPF argued that the DOCTYPE statement for SVG must not be allowed for this reason. This happened during the development of EPUB3.

  14. llemeurfr commented on Oct 12, 2020

    @llemeurfr
    Contributor
  15. 74 remaining items

  16. mattgarrish commented on Oct 26, 2020

    @mattgarrish
    Member

    Is there really a user need behind these?

    I find it doubtful. No offense, as I grew up on SGML, but we're partying like it's 1999 in this thread... :)

    XSLT is the the more usual language of choice these days if publishers want to insert boilerplate, repeated strings, etc.

    Your proposal seems similar to where we were somewhere way back in this thread (although I'm not sure how we disagreed on the wording and I'm not going to try and locate why). External identifiers are disallowed except for a controlled list and reading systems ignore (that has to be separately in the RS spec, though).

    Works for me.

  17. iherman commented on Oct 26, 2020

    @iherman
    MemberAuthor

    I have just realized that we should not forget to add the ONIX DTD (or DTDs?) to our controlled list:

    <!DOCTYPE ONIXMessage SYSTEM "http://www.editeur.org/onix/2.1/02/reference/onix-international.dtd">
    

    after all, it should be possible to add the ONIX metadata as part of the package...

  18. iherman commented on Oct 26, 2020

    @iherman
    MemberAuthor

    Your proposal seems similar to where we were somewhere way back in this thread

    yep, we made a big circle...

  19. mattgarrish commented on Oct 26, 2020

    @mattgarrish
    Member

    I have just realized that we should not forget to add the ONIX DTD (or DTDs?) to our controlled list:

    Maybe no harm, but not sure how critical it is. My understanding is they're pushing to move everyone to 3.0 now and 3.0 records aren't supposed to be distributed with a doctype.

    I don't believe ONIX records actually end up in EPUBs all that often, either.

  20. iherman commented on Oct 26, 2020

    @iherman
    MemberAuthor

    To be honest, I do not know. SOmething to be checked, possibly with Graham...

  21. clapierre commented on Oct 26, 2020

    @clapierre
    Contributor

    ONIX files are out-of-band metadata that publishers send out separate from the EPUB. a lot of times aggregators and distributors get only the ONIX files to determine what EPUBs they want. Also publishers can send these ONIX files with updates say pricing changes etc. without updating the EPUB itself.

  22. iherman commented on Oct 26, 2020

    @iherman
    MemberAuthor

    If we go down the road of listing some 'acceptable' XML DTD-s (see #1338 (comment)) then adding an ONIX DTD is painless. I realize that it does not happen often, but we should not make it impossible to add an ONIX file into the EPUB container...

  23. murata2makoto commented on Oct 27, 2020

    @murata2makoto
    Contributor

    I just created #1369, #1370, #1371, and #1372. Hopefully, all sub-issues are easier

  24. murata2makoto commented on Oct 27, 2020

    @murata2makoto
    Contributor

    Created another issue (#1373) for ONIX.

  25. avneeshsingh commented on Oct 27, 2020

    @avneeshsingh

    +1 to have the solution that works for ONIX also. Most of times ONIX is external metadata but during ISO process of EPUB Accessibility, we observed interest in having ONIX accessibility metadata also as internal metadata.

  26. murata2makoto commented on Oct 28, 2020

    @murata2makoto
    Contributor

    This article is interesting. It mentions a massive DDoS attack on the W3C web site all the time.

  27. iherman commented on Nov 6, 2020

    @iherman
    MemberAuthor

    This issue was discussed in a meeting.

    • RESOLVED: Merge PR #1368 to address outstanding DTD issues, and close GH issues 1369-1373
    View the transcript Wendy Reid: we had resolutions at the F2F, and further discussions on github
    … and came to a happy place
    Matt Garrish: #1368
    Matt Garrish: where we ended up was…
    … we put in an allowance for a specific set of external identifiers that we have put in an appendix
    … we have SVG and MathML that are allowed to be used in content docs or in separate files
    … and we made a restriction against external entities in the internal DTD subset
    … so it prevents some security issues but eases authoring
    … so we’ll no longer force people to remove SVG DTDs from tool-generated files
    … I’m hoping this is it :)
    Ivan Herman: tech comment
    … in fact, the changes are such that
    … makes possible something that I’m not sure we really use
    … I can define as part of an internal entity something that won’t go out to the network
    … I’m not sure if this feature is in use
    … formal comment
    … there was a formal resolution on the previous version; this PR slightly changes that
    … can we get a formal resolution to merge, and also close a bunch of issues which were examples of the problem?
    Proposed resolution: Merge PR #1368 to address outstanding DTD issues, and close GH issues 1369-1373 (Wendy Reid)
    Garth Conboy: +1
    Matt Garrish: +1
    Ivan Herman: +1
    Charles LaPierre: +1
    Matthew Chan: +1
    Wendy Reid: +1
    Brady Duga: +1
    George Kerscher: +1
    Laura Brady: +1
    Bill Kasdorf: +1
    Ben Schroeter: +1
    Resolution #1: Merge PR #1368 to address outstanding DTD issues, and close GH issues 1369-1373
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

    EPUB33Issues fixed in the EPUB 3.3 revisionSpec-EPUB3The issue affects the core EPUB 3.X Recommendation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions