Relax HTML sniffing checks on image upload
authorBrion Vibber <brion@pobox.com>
Thu, 6 Jun 2019 21:54:29 +0000 (14:54 -0700)
committerBrion Vibber <brion@pobox.com>
Fri, 7 Jun 2019 21:21:00 +0000 (14:21 -0700)
commit2e83387666756039129fd4e8f667dc5fed0849f3
tree524556635513e15a99e310eef21c011925dd912d
parent23ef4c44eeac8881d3c31701fdeb59a5ba3b6be5
Relax HTML sniffing checks on image upload

Allows uploaded files to include some HTML tag strings that were
previously forbidden in the first 1k or so of the file:
* <a href
* <img
* <pre
* <table
* <title

They are now allowed as long as the IE MIME type detection heuristic
would not change their types. This should reduce the number of false
positive checks in JPEGs with EXIF data with links.

Also deprecates $wgAllowTitlesInSVG and allows it by default.

This should still protect against malformed PNG attacks on old IE
versions, though false positive checks are conceivable on PNG files
containing comments very close to the beginning of the file.

Adds $wgVerifyMimeTypeIE config var to allow disabling the IE checks
entirely, if desired, but leaves it in place by default. These are
more conservative than the checks that were removed.

Added test cases for the old IE5/6 bug and the particular sort of
JPEG metadata that struck false positives previously.

Bug: T27707
Change-Id: I66642a74fce1a1894cad67d62b0da61020db469a
RELEASE-NOTES-1.34
includes/DefaultSettings.php
includes/upload/UploadBase.php
tests/phpunit/data/upload/jpeg-a-href-in-metadata.jpg [new file with mode: 0644]
tests/phpunit/data/upload/png-embedded-breaks-ie5.png [new file with mode: 0644]
tests/phpunit/data/upload/png-plain.png [new file with mode: 0644]
tests/phpunit/includes/upload/UploadBaseTest.php