UploadBase: Permit SVG files with broken namespace definition (Inkscape bug)
authorBartosz Dziewoński <matma.rex@gmail.com>
Wed, 5 Oct 2016 20:18:39 +0000 (22:18 +0200)
committerBrian Wolff <bawolff+wn@gmail.com>
Thu, 27 Oct 2016 10:24:32 +0000 (10:24 +0000)
commit19d692051f08985363f0f7c02c7ff08b3936ea3d
tree41d93f1bb7aa34ec802eb6fa614e4a176c9ea817
parent24200e88d243b160f1ac6b6a8e71a7aab9e35550
UploadBase: Permit SVG files with broken namespace definition (Inkscape bug)

Inkscape mangles namespace definitions created by Adobe Illustrator
(apparently it can't parse custom entities or something, maybe just
in 'xmlns' attributes). These files are still valid SVG, and not
a security issue (although Illustrator probably won't like them),
so it's okay to allow them.

Added tests with some example files.

* buggynamespace-original.svg
  File generated by Illustrator (edited by hand to reduce filesize).
  Based on <https://commons.wikimedia.org/w/?curid=16495597>.

* buggynamespace-okay.svg
  The original file, opened and saved in Inkscape (no other changes).

* buggynamespace-okay2.svg
  The original file, opened and saved in Inkscape twice.

* buggynamespace-bad.svg
  The original file, edited by hand to remove custom entities.
  This is not valid XML and should be rejected (although it's valid
  when parsed as HTML, and some image viewers might display it).

* buggynamespace-evilhtml.svg
  An SVG file using an entity declared namespace for a namespace
  we want to ban. Based on buggynamespace-original.svg.

Bug: T144827
Change-Id: I0eb9766cab86a58d729f10033c64f57d2076d917
includes/upload/UploadBase.php
tests/phpunit/data/upload/buggynamespace-bad.svg [new file with mode: 0644]
tests/phpunit/data/upload/buggynamespace-evilhtml.svg [new file with mode: 0644]
tests/phpunit/data/upload/buggynamespace-okay.svg [new file with mode: 0644]
tests/phpunit/data/upload/buggynamespace-okay2.svg [new file with mode: 0644]
tests/phpunit/data/upload/buggynamespace-original.svg [new file with mode: 0644]
tests/phpunit/includes/upload/UploadBaseTest.php