epubcheck icon indicating copy to clipboard operation
epubcheck copied to clipboard

"rel" attribute disallowed in "a" element inside "svg" element (epubcheck 4.2.2)

Open GarthConboy opened this issue 4 years ago • 7 comments

The nesting in the title yields the following error:

      error {
        resource: "OEBPS/page_22.xhtml"
        line: 11
        column: 1431618
        description: "Error while parsing file: attribute \"rel\" not allowed here; expected attribute \"alignment-baseline\", \"aria-activedescendant\", \"aria-atomic\", \"aria-autocomplete\", \"aria-busy\", \"aria-checked\", \"aria-colcount\", \"aria-colindex\", \"aria-colspan\", \"aria-controls\", \"aria-current\", \"aria-describedby\", \"aria-details\", \"aria-disabled\", \"aria-dropeffect\", \"aria-errormessage\", \"aria-expanded\", \"aria-flowto\", \"aria-grabbed\", \"aria-haspopup\", \"aria-hidden\", \"aria-invalid\", \"aria-keyshortcuts\", \"aria-label\", \"aria-labelledby\", \"aria-level\", \"aria-live\", \"aria-modal\", \"aria-multiline\", \"aria-multiselectable\", \"aria-orientation\", \"aria-owns\", \"aria-placeholder\", \"aria-posinset\", \"aria-pressed\", \"aria-readonly\", \"aria-relevant\", \"aria-required\", \"aria-roledescription\", \"aria-rowcount\", \"aria-rowindex\", \"aria-rowspan\", \"aria-selected\", \"aria-setsize\", \"aria-sort\", \"aria-valuemax\", \"aria-valuemin\", \"aria-valuenow\", \"aria-valuetext\", \"baseline-shift\", \"class\", \"clip\", \"clip-path\", \"clip-rule\", \"color\", \"color-interpolation\", \"color-interpolation-filters\", \"color-profile\", \"color-rendering\", \"cursor\", \"direction\", \"display\", \"dominant-baseline\", \"enable-background\", \"externalResourcesRequired\", \"fill\", \"fill-opacity\", \"fill-rule\", \"filter\", \"flood-color\", \"flood-opacity\", \"focusable\", \"font-family\", \"font-size\", \"font-size-adjust\", \"font-stretch\", \"font-style\", \"font-variant\", \"font-weight\", \"glyph-orientation-horizontal\", \"glyph-orientation-vertical\", \"href\", \"id\", \"image-rendering\", \"kerning\", \"letter-spacing\", \"lighting-color\", \"marker-end\", \"marker-mid\", \"marker-start\", \"mask\", \"ns:type\", \"onactivate\", \"onclick\", \"onfocusin\", \"onfocusout\", \"onload\", \"onmousedown\", \"onmousemove\", \"onmouseout\", \"onmouseover\", \"onmouseup\", \"opacity\", \"overflow\", \"pointer-events\", \"requiredExtensions\", \"requiredFeatures\", \"role\", \"shape-rendering\", \"stop-color\", \"stop-opacity\", \"stroke\", \"stroke-dasharray\", \"stroke-dashoffset\", \"stroke-linecap\", \"stroke-linejoin\", \"stroke-miterlimit\", \"stroke-opacity\", \"stroke-width\", \"style\", \"systemLanguage\", \"tabindex\", \"text-anchor\", \"text-decoration\", \"text-rendering\", \"transform\", \"unicode-bidi\", \"visibility\", \"word-spacing\", \"writing-mode\", \"xlink:actuate\", \"xlink:arcrole\", \"xlink:role\", \"xlink:show\", \"xlink:title\", \"xlink:type\", \"xml:base\", \"xml:lang\" or \"xml:space\" (with xmlns:ns=\"http://www.idpf.org/2007/ops\") or an attribute from another namespace"
        message_id: "RSC-005"
      }

An extract of markup would be (ellipses indicate clipped markup):

<body id="68c60dac_body">
<div>
<svg width="100%" height="100%" viewBox="0.0 0.0 960.0 720.0" fill="none" stroke="none" stroke-linecap="square" stroke-miterlimit="10" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg">
<g ...>
...
<a xlink:href="https://..." target="_blank" rel="noreferrer">
...
</g>
</svg>
</div>
</body>

I think this should be okay. Does the SVG schema need updating?

GarthConboy avatar Aug 03 '20 22:08 GarthConboy

Yes, it's valid, but the schemas don't fully support svg2.

I've opened an issue against the nu validator to add: https://github.com/validator/validator/issues/1008

mattgarrish avatar Aug 03 '20 23:08 mattgarrish

I am not an svg expert, but I am concerned that it will be difficult to validate svg in the era of living standards. An svg 1.1 validator should reject the example since rel wasn't allowed on a elements in that version. While it is now allowed in svg 2, an svg 2 validator should reject the example because the svg element has a version attribute which is no longer allowed. Are we using (or proposing) some sort of hybrid validator? I wonder if the correct answer is to not worry about svg validation, but that is a larger discussion.

bduga avatar Aug 04 '20 16:08 bduga

Are we using ... some sort of hybrid validator?

That's what I understand is done for the nu validator based on this discussion I found.

For epubcheck, my understanding is that we want to be in sync with web validation generally, except where epub specifically diverges, so that you don't get mixed signals. That isn't entirely possible at this stage, since we only use the schemas and not the additional java checks, but I believe fuller integration might come in a later refactor of epubcheck.

No opinion here on whether or not to check svg, though. That would be a discussion for the main group to pick up.

mattgarrish avatar Aug 04 '20 18:08 mattgarrish

Note that I updated the initial description of this bug to remove version="1.1" which was technically wrong for including "rel" inside an SVG nested "a" element. No change in behavior... except now the bug report is now completely correct (I think!).

GarthConboy avatar Aug 04 '20 20:08 GarthConboy

Another example of a similar issue is this error:

ERROR(RSC-005): target.epub/OEBPS/page_22.xhtml(11,81921): Error while parsing file: attribute "fill" not allowed here; expected attribute "aria-activedescendant", "aria-atomic", "aria-autocomplete", "aria-busy", "aria-checked", "aria-colcount", "aria-colindex", "aria-colspan", "aria-controls", "aria-current", "aria-describedby", "aria-details", "aria-disabled", "aria-dropeffect", "aria-errormessage", "aria-expanded", "aria-flowto", "aria-grabbed", "aria-haspopup", "aria-hidden", "aria-invalid", "aria-keyshortcuts", "aria-label", "aria-labelledby", "aria-level", "aria-live", "aria-modal", "aria-multiline", "aria-multiselectable", "aria-orientation", "aria-owns", "aria-placeholder", "aria-posinset", "aria-pressed", "aria-readonly", "aria-relevant", "aria-required", "aria-roledescription", "aria-rowcount", "aria-rowindex", "aria-rowspan", "aria-selected", "aria-setsize", "aria-sort", "aria-valuemax", "aria-valuemin", "aria-valuenow", "aria-valuetext", "class", "clip", "clip-rule", "color", "color-interpolation", "color-profile", "color-rendering", "cursor", "display", "externalResourcesRequired", "fill-opacity", "filter", "focusable", "height", "href", "id", "image-rendering", "mask", "ns:type", "onactivate", "onclick", "onfocusin", "onfocusout", "onload", "onmousedown", "onmousemove", "onmouseout", "onmouseover", "onmouseup", "opacity", "overflow", "pointer-events", "preserveAspectRatio", "requiredExtensions", "requiredFeatures", "role", "shape-rendering", "stroke-opacity", "style", "systemLanguage", "tabindex", "text-rendering", "transform", "vector-effect", "visibility", "width", "x", "xlink:actuate", "xlink:arcrole", "xlink:href", "xlink:role", "xlink:show", "xlink:title", "xlink:type", "xml:base", "xml:lang", "xml:space" or "y" (with xmlns:ns="http://www.idpf.org/2007/ops") or an attribute from another namespace

when presented with:

<body id="68c60dac_body">
<div>
<svg width="100%" height="100%" viewBox="0.0 0.0 960.0 720.0" fill="none" stroke="none" stroke-linecap="square" stroke-miterlimit="10" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg">
<g ...>
...
<image clip-path="url(#g4d46da3d71_0_0.1)" fill="#000" width="719.0" height="483.0" x="0.0" y="0.0" preserveAspectRatio="none" xlink:href="data:image/png;base64,iVBO ... ">
...
</g>
</svg>
</div>
</body>

GarthConboy avatar Aug 04 '20 20:08 GarthConboy

I think that SVG validation should not be lifted, since maintenance of EPUB assets containing invalid SVG fragments is likely to be annoying.

murata2makoto avatar Aug 04 '20 22:08 murata2makoto

While I'm fine if the EPUB specs ultimately do not require validity for conformance, it would greatly reduce the usefulness of epubcheck if we stop checking the validity of SVG and XHTML files completely.

Perhaps we need to consider other options, like defining a separate message category for validity issues or only strictly validating if a flag is set.

mattgarrish avatar Oct 10 '20 12:10 mattgarrish

SVG content model checks are now informative only since #1365.

rdeltour avatar Dec 08 '22 08:12 rdeltour