Page MenuHomePhabricator

Consider safely optimizing embedded SVG icons in MediaWiki core
Closed, ResolvedPublic

Description

We may want to consider safely optimizing embedded SVG icons.

https://gerrit.wikimedia.org/r/96372
https://gerrit.wikimedia.org/r/103894

Full background is available at bug 59234.

(Copied from bug 59234 comment 27)

This seems to have been fixed in file 5.04; however, PHP uses a bundled,
patched copy of the library that was only updated from 5.03 to 5.11 in
12cf930a403d.

Running "git tag --contains 12cf930a403d" in php-src tells me that
affected versions of PHP were 5.3.10 and older, as well as 5.4.0.
Wikimedia runs 5.3.10 in production.

Here's a snippet of the diff:

  • file-5.03/magic/Magdir/sgml 2008-07-26 11:03:55.000000000 -0400

+++ file-5.04/magic/Magdir/sgml 2009-09-19 13:31:35.000000000 -0400
@@ -1,36 +1,59 @@

#------------------------------------------------------------------------------
+# $File: sgml,v 1.24 2009/09/19 17:31:35 christos Exp $

  1. Type: SVG Vectorial Graphics
  2. From: Noel Torres <tecnico@ejerciciosresueltos.com> 0 string \<?xml\ version=" >15 string >\0

->>23 search/400 \<svg SVG Scalable Vector Graphics image
+>>19 search/4096 \<svg SVG Scalable Vector Graphics image
!:mime image/svg+xml

Note that the start offset of the search for "<svg" was dropped from 23 to 19,
and the newer, shorter XML declaration was the following 22-character string:

<?xml version="1.0" ?>

So this problem could have been avoided by either adding a DOCTYPE or leaving
one more whitespace character in the right place.


Version: 1.23.0
Severity: enhancement
See Also:
https://bugzilla.wikimedia.org/show_bug.cgi?id=34812

Details

Reference
bz59744

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 2:24 AM
bzimport set Reference to bz59744.

Change 106506 had a related patch set uploaded by Bartosz Dziewoński:
Optimize all SVGs (attempt 2)

https://gerrit.wikimedia.org/r/106506

Change 111982 had a related patch set uploaded by Bartosz Dziewoński:
Drop dead code from all SVG source files

https://gerrit.wikimedia.org/r/111982

Change 111982 merged by jenkins-bot:
Drop dead code from all SVG source files

https://gerrit.wikimedia.org/r/111982

(That patch was actually done by Thiemo Mättig, I just linked it to this bug. My own more aggressive optimisation patch submitted earlier needs some more work.)

Change 112234 had a related patch set uploaded by Bartosz Dziewoński:
Vector: Simplify text paths in tiny icons

https://gerrit.wikimedia.org/r/112234

Change 112234 merged by jenkins-bot:
Vector: Simplify text paths in tiny icons

https://gerrit.wikimedia.org/r/112234

Change 106506 merged by jenkins-bot:
Optimize all SVGs

https://gerrit.wikimedia.org/r/106506

Okay, the SVG files in core should be all fixed up.

Bug 63491 tracks magically optimizing them on-the-fly in ResourceLoader.