• Hi! We run all our websites through the W3C Validator and we are getting this error:

    Saw <?. Probable cause: Attempt to use an XML processing instruction in HTML. (XML processing instructions are not supported in HTML.)

    That error is being caused by this XML tag being appended to our SVGs when they are being uploaded: <?xml version=”1.0″ encoding=”UTF-8″?>

    I assume that the Safe SVG plugin is doing that, correct? Is there a way to prevent that so we aren’t getting errors in the W3C Validator? Thanks for checking on this!

    Joel

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Contributor Daryll Doyle

    (@enshrined)

    Hi Joel,

    I’m sorry you’re seeing this issue, are you using the SVG’s that you upload inline rather than in <img> tags?

    There’s no way to fix this automatically in the current version of Safe SVG as some people want the XML declaration to stay intact. That said, you could potentially remove the XML declaration manually before upload which wouldn’t take too long and would fix the issue you’re having?

    There’s also the possibility to do this automatically using a function in your theme/a small plugin. How you’re loading the files will make all the difference though!

    Cheers,
    Daryll

    Thread Starter joelnewcomer

    (@joelnewcomer)

    Hi Daryll, thank you for your quick response! Yes, we are using them inline. The SVGs we are uploading don’t have the XML declaration in them. The XML declaration is being pre-pended after the file is uploaded and I assumed that the Safe SVG plugin was doing that but maybe it is another plugin causing that or possibly something in WordPress core. The SVG before being uploaded does not contain this:

    <?xml version=”1.0″ encoding=”UTF-8″?>

    But after uploading it to the media library, it does. Thanks for your help! I’ll post back here if I find out what is causing that. Thanks again!

    Joel

    Thread Starter joelnewcomer

    (@joelnewcomer)

    Hi Daryll, I did a clean WordPress install with no plugins other that Safe SVG and it is still pre-pending SVGs with the XML declaration, so I assume it is WordPress core that is doing that? Thanks again!

    Joel

    I would suspect that WordPress is adding it, but I am not an expert. When you view source on an SVG upload from the media library link, does it have the <?xml tag? Do you have PHP short tags enabled (I assume not)? Is it feasible to modify WordPress image fetching functions (for SVG files) with file_get_contents() (or similar) instead? I’m just spit-balling… Is this hosted with a shared provider, or your own environment? (thinking maybe they have something in place to add the tag where absent, though that would be odd)

    As an experiment, you could try using a different plugin to maybe/possibly help troubleshoot the cause. Note that I prefer Safe SVG uber alles and would switch back – I’m just trying to come up with ideas to narrow down the culprit.

    Though, as Daryll mentioned, I have a feeling that it may be prudent and maximize compatibility to use a filter.

    • This reply was modified 6 years, 6 months ago by Daniel Hendricks. Reason: Added note re: Daryll's suggestion
    Plugin Contributor Daryll Doyle

    (@enshrined)

    Hi @joelnewcomer,

    If the file doesn’t contain the XML declaration before upload then it is quite possible that it is Safe SVG adding it once the file has been sanitised and saved.

    At this time there’s no way to filter the options of the sanitiser but I will look into adding this shortly.

    In the meantime, if you can share the code that you’re using to load the SVGs inline, I can help you write a function to remove the XML declaration. Feel free to send it over to [email protected] or paste it here. Whichever is easier for you!

    @hendridm, thank you for your help too. I always know people are in safe hands when your name pops up ??

    Cheers,
    Daryll

    Thread Starter joelnewcomer

    (@joelnewcomer)

    @hendrim @enshrined Thanks for your feedback! I am using get_template_part() in some places and file_get_contents() in other places to load the SVGs inline. @hendrim I did try another plugin (SVG Support) and had the same results. The website is hosted on WP Engine and SVGs that I push up using Git are not affected, only SVGs uploaded to the media library. @enshrined I can write a function to remove the XML declaration, but it would be awesome if you could add an option to your plugin to automatically remove it. Thanks again! You guys are awesome! For now I’m just going to turn a blind eye to the few W3C Validator errors.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘W3C Validator’ is closed to new replies.