filter working code example + disallowed risk reference
-
Hi,
We use Safe SVG to make svg possible in a site with<object>
tags, currently in development on our internal network.
<object data="/wp-content/uploads/2019/07/wheel.svg"></object>
Our svg uses anchor links to other parts of our site, Illustrator default uses xlink:href tags.
<a xlink:href="#anchor">
When those links are used, the object is seen as an iframe and will load the content of the link inside the object space.
To resolve that I edited the svg after output of Illustrator.
Changed xlink:href to href (since it will be deprecated in future version of svg) and addedtarget="_top"
to open the link outside of the object. But the target attribute gets sanitized out of the svg by Safe SVG.According to your faq, you can allow attributes and tags with svg_allowed_attributes and svg_allowed_tags filters.
I know the code has to be put inside the functions.php of the used (child)theme, but I have no clue what to code in the// Do what you want here...
part.Currently I edited
/wp-content/plugins/safe-svg/lib/vendor/enshrined/svg-sanitize/src/data/AllowedAttributes.php
to allow the target attribute due to lack of knowledge of using the filter. Not wise with future version updates, but it works for the moment.My questions:
- Can you perhaps show a complete working code example of allowing the target attribute?
- Do you perhaps have a reference of the disallowed tags and attributes with the related risks when allowed?
Kind regards,
Yggy
- The topic ‘filter working code example + disallowed risk reference’ is closed to new replies.