* Make it actually check against the URI length, not file size.
Previous code could produce URIs that edged just over the limit.
* Replace $sizeLimit parameter with $ie8Compat, because that's the
only use case and the file size limit approach was flawed per above,
anyway.
* Remove CSSMin::EMBED_SIZE_LIMIT constant, which is not used anymore.
CSSMin::DATA_URI_SIZE_LIMIT still exists.
* Change code flow to avoid repetition.
* Split off new method, encodeStringAsDataURI(), that does actual
encoding rather than file handling.
Change-Id: I3704404ce831d7e0f6e3a65f23c76f313ad13238
Do not base64-encode non-binary files (containing only whitespace and
printable ASCII characters, which matches sane SVG files).
For SVG files the percent-encoded URIs are actually slightly longer
than the base64-encoded ones (~10%), but compress a lot better
resulting on 15-20% less data to transfer after gzip compression.
(The effect is best seen on the 'oojs-ui' module, which consists
mostly of SVG icons – especially after commenting out everything other
than 'oojs-ui.svg.css'.)
I tried this for binary files too, just in case; but as expected, they
suffer from a noticeable size increase even with compression (~15%).
Bug: 67341
Change-Id: Iddaf863b6be98570a2bb8e606f13946a96345f65
This reverts most of commit 2d842f1425,
leaving only the test added in it, and reimplements the same
functionality better.
Instead of stripping /*@noflip*/ annotations in CSSJanus, which is
incompatible with other implementations that preserve it, extend
CSSMin to allow other CSS comments to be present before the
rule-global @embed annotation. (This required making the regex logic
in it even worse than it was, but it's actually slightly less terrible
than I expected it would be. Good thing we have tests!)
Bug: 69698
Change-Id: I58603ef64f7d7cdc6461b34721a4d6b15f15ad79
Since PHP 5.3, mime_content_type() is implemented as part of PHP's
fileinfo extension and thus is deprecated in favor of the newer
alternatives provided by that extension (already in use).
Also updated a comment in DefaultSettings.php that mentioned the
function. Did not modify lessc.inc.php, a third-party library
maintained separately from MediaWiki.
Change-Id: Ic4a0873989ddb634ec9a05c3340941a9ba3f5ec5
Remapping of url()s was thrown off if the CSS contained comments
with curly braces. To fix, replace all block comments (except @embed
directives) with placeholders before url() processing and swap them
back in afterwards. Patch also includes tests.
Bug: 60077
Change-Id: If18a93c17ea9bcd529f6a664aa2dcc51d4a37f38
If it's a URL, it obviously can't be a local file; check that first to
avoid PHP warnings about malformed paths.
Bug: 60960
Change-Id: Id784c089c3de8af79af7524ef5ab5cc2f7b8af9e
The function used to check if the $path parameter is null on every
inner loop iteration, only to effectively return an empty array if it
was. Rephrased the code to say exactly that.
(Not sure what the behavior is good for, though…)
Change-Id: I716bfde581d3ed4c02f0d9f544beb9d0a1906261
Introduce new static function, CSSMin::buildUrlValue.
Actually using such values in CSS does not work well because the
URL_REGEX is nowhere near good enough. :(
Change-Id: I04a7078dd0087bcb461fa5e5168c870d37c255f4
We would previously return the path to the local file on the
filesystem, which is useless in all cases and possibly a security
issue in some. Now we return the URL at which the file would be
accessible had it existed.
Also reordered the code around that part to make the control flow
clearer and added a test.
Change-Id: I1d5befb2ea385ae4d316c5d8c5d1fc092b64c4ff
Each can be selectively embedded by placing the /* @embed */ comment
just before the url() value. /* @embed */ at the beginning of the rule
affects all url() values appearing in it.
Three changes in existing behavior for previously supported syntax:
* /* @embed */ comments are no longer preserved in output
* rules not terminated by semicolons are correctly supported
* spaces within url() values are correctly supported
Bug: 46757
Bug: 56514
Change-Id: If9082f553fa920c606f12093f39f4a163ebacc32
The code for encoding suitable images as base64 data URIs was previously part
of the remap method of CSSMin, which greps CSS files for /* @embed */
annotations. This patch moves it into its own method, encodeImageAsDataURI.
Change-Id: I6f57116c6a6c18ff9d4e28760dd484ea2c8fc493
There's no reason why it should be protected. People sometimes use
'protected' to mean 'ancillary to the main purpose of the class', but
'protected' comes with the added cost of making the class API less
flexible. I intend to call this method in a future revision of Id052a04dd2,
but I think it should be public regardless.
Change-Id: I56365df3152df1180ce73de98202e3a91def1485
Doxygen expects parameter types to come before the
parameter name in @param tags. Used a quick regex
to switch everything around where possible. This
only fixes cases where a primitve variable (or a
primitive followed by other types) is the variable
type. Other cases will need to be fixed manually.
Change-Id: Ic59fd20856eb0489d70f3469a56ebce0efb3db13
* No need to strip them from everywhere all over. This bug is only
caused by the presence of a trailing slash on $remote.
* To make sure everything still works before and after I added
unit tests for CSSMin in Ic9195614acfd, making this dependent
on that change.
Change-Id: Ia82048a328a056117afe0d653fe22f5429b21f5a
CSSMin::minify()'s processing of url references for path adjustment or embedding had excluded explicit fully-qualified http: and https: URLs, but was damaging others such as data: URIs that were actually hardcoded into the original CSS.
This was affecting styles used on no.wikipedia.org which embedded a few icons directly into the style sheet.
Now checking for any URL scheme rather than hardcoding a check for http & https.