Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Produces invalid SVG when namespaced attributes appear before namespace declaration #1288

Open
diegoatpitch opened this issue May 13, 2024 · 1 comment

Comments

@diegoatpitch
Copy link

Just got a browser complaining about parsing the SVG output of Imgproxy.
Debugging the file it seems to be an issue with the ordering of attributes on the svg element. I could produce a minimal example.

Input:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
  version="1.1"
  viewBox="0 0 200 200"
  x="0px"
  y="0px"
  width="200"
  height="200"
  sodipodi:docname="my.svg"
  inkscape:version="1.2.2 (732a01da63, 2022-12-09)"
  inkscape:export-filename="..\Desktop\my.svg"
  xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
  xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
  xmlns="http://www.w3.org/2000/svg"
  xmlns:svg="http://www.w3.org/2000/svg"
>
  <svg:rect width="100%" height="100%" fill="green" />
</svg>

Output:

<svg
  viewBox="0 0 200 200"
  width="200"
  height="200"
  sodipodi:docname="my.svg"
  inkscape:version="1.2.2 (732a01da63, 2022-12-09)"
  inkscape:export-filename="..\Desktop\my.svg"
  xmlns="http://www.w3.org/2000/svg"
  xmlns:svg="http://www.w3.org/2000/svg"
>
  <svg:rect width="100%" height="100%" fill="green"/>
</svg>

sodipodi and inkscape namespaces got removed but not the attributes.

Now, if the input SVG is the same but with namespaced attributes after the namespace declarations, it works.

Input:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
  version="1.1"
  viewBox="0 0 200 200"
  x="0px"
  y="0px"
  width="200"
  height="200"
  xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
  xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
  xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg"
  sodipodi:docname="my.svg"
  inkscape:version="1.2.2 (732a01da63, 2022-12-09)"
  inkscape:export-filename="..\Desktop\my.svg"
>
  <svg:rect width="100%" height="100%" fill="green" />
</svg>

Output:

<svg
  viewBox="0 0 200 200"
  width="200"
  height="200"
  xmlns="http://www.w3.org/2000/svg"
  xmlns:svg="http://www.w3.org/2000/svg"
>
  <svg:rect width="100%" height="100%" fill="green"/>
</svg>
@DarthSim
Copy link
Member

Hey @diegoatpitch!

Thanks for another sample! Fixed in the latest build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants