Commit graph

51 commits

Author SHA1 Message Date
Trevor Parscal
3e2fd810d2 Revert "Fix "CSSMin url() value remapping not working in certain obscure cases""
This reverts commit fa1053a16a.

Breaks CSS output, making the skin and extensions look unstyled.

Change-Id: I297150f775dd5559f91f2c9c25c64b134459c6b6
2014-06-10 22:04:40 +00:00
Stephan Gambke
fa1053a16a Fix "CSSMin url() value remapping not working in certain obscure cases"
This patch extends the regex used to find URLs by css block quote subpatterns.

Bug: 60077
Change-Id: Ife00d01b78c6369f20ffc49d20aa58e354a61ee7
2014-06-09 23:50:28 +02:00
Siebrand Mazeland
40e04816f0 Pass phpcs-strict on includes/libs/
No changes to "real" libs. They are excluded from CodeSniffer tests.

Change-Id: Ifd14c0be24014fd9629a31e9bd155b27e2c0e93d
2014-04-24 21:48:10 +02:00
Bartosz Dziewoński
603174ff41 CSSMin: Don't do file_exists on random data in getLocalFileReferences()
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
2014-03-10 20:55:02 +01:00
Bartosz Dziewoński
ae839a0fac CSSMin: Clean up the logic in getLocalFileReferences()
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
2014-02-28 21:26:56 +01:00
Reedy
05b70dc29e Remove unreachable statement
Change-Id: I79175695698a6ef393eff841580263c867719e25
2014-01-30 04:06:03 +00:00
jenkins-bot
2fd7a38349 Merge "Add SVG versions of enhanced recent changes collapse/show arrows" 2013-12-27 22:38:54 +00:00
m4tx
3b3042891e Add SVG versions of enhanced recent changes collapse/show arrows
Bug: 35344
Change-Id: I1fcc255691048cb8929a68096e1e0e56e934f020
2013-12-27 23:32:17 +01:00
Bartosz Dziewoński
2c866d8e73 CSSMin: Correctly format 'url()' values with parentheses etc.
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
2013-12-11 22:22:59 +01:00
Bartosz Dziewoński
e36dcfa4c6 CSSMin: Change behavior for missing files
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
2013-12-11 21:21:36 +01:00
Bartosz Dziewoński
3987b10b51 CSSMin: Fix remapOne() for URLs that are proto-relative or have query part
Bug: 58338
Change-Id: I836a2c054ae3edc07895b2388f4ec8663223347a
2013-12-11 20:58:28 +01:00
Bartosz Dziewoński
f3779e067f Rewrite CSSMin::remap to support multiple url() values in one rule
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
2013-11-29 18:23:33 +00:00
Ori Livneh
755f0a9fc6 CSSMin: factor out image encoding into encodeImageAsDataURI method
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
2013-09-18 15:09:20 -07:00
Ori Livneh
adee3374bf Make CSSMin::getMimeType public rather than protected
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
2013-09-18 04:09:21 +00:00
Tyler Anthony Romeo
4dcc7961df Fixed @param tags to conform with Doxygen format.
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
2013-03-11 13:15:01 -04:00
Timo Tijhof
90fd3bdea5 CSSMin: Clean up $remote trailing slash fix
* 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
2012-06-20 14:30:10 +02:00
Alexandre Emsenhuber
63176b99b7 Added missing GPLv2 headers in some places.
Also made file/class documentation more consistent.

Change-Id: I1deb70318d01a257b51948ba806d80cd1a239f4f
2012-05-04 08:47:07 +02:00
Roan Kattouw
23ab0f7162 (bug 34114) CSSMin::remap() doesn't respect its $embed parameter. Patch by Gilles van den Hoven 2012-02-02 10:30:57 +00:00
Sam Reed
4622da783c More documentation! 2011-10-26 04:15:09 +00:00
Sam Reed
27665d27ae Update some deprecated code
Documentation

Fix "/*" comments to "/**"

Flesh out some missing returns, change some return types
2011-10-14 21:18:38 +00:00
Roan Kattouw
b3599d8f8c Followup to r92580 and r93820: r92580 duplicated the call to wfExpandUrl(), and r93820 caused them to get out of sync. 2011-08-14 13:35:06 +00:00
Roan Kattouw
3e0a770524 Fix syntax error in r93820 2011-08-03 13:12:55 +00:00
Roan Kattouw
ae7d7676fb Fix r93820: PROT_ -> PROTO_ 2011-08-03 13:11:42 +00:00
Roan Kattouw
6adb2e86a5 Some random URL protocol forcing for protocol-relative URLs 2011-08-03 12:58:21 +00:00
Roan Kattouw
cb8418647f Fixes for URL expanding in CSSMin: adjust the offset correctly (this could've theoretically resulted in very strange bugs) and only call wfExpandUrl() if available (the file is in includes/libs so it should work outside of MediaWiki) 2011-07-19 21:19:50 +00:00
Sam Reed
bdf84cb20e Swap else if for elseif
Trimming trailing whitespace also

Doing in 3 commits, so hopefully reviewable in CR...
2011-06-17 16:03:52 +00:00
Brion Vibber
5feb09f086 * (bug 25262) Fix for minification of hardcoded data: URIs in CSS
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.
2011-05-10 20:14:30 +00:00
Ryan Kaldari
55fc4f6a86 oops, don't delete char before the slash, followup to r83902 2011-03-15 02:03:01 +00:00
Ryan Kaldari
754e09b59b keep double slash filter from breaking absolute URLs, fix to r83902 2011-03-15 01:57:37 +00:00
Roan Kattouw
797544d3a3 (bug 27052) CSSMin generated URLs like foo//../bar in some cases, which apparently resolves to foo/bar rather than foo/../bar or bar . Fixed by eliminating duplicate slashes from the file URL when remapping 2011-03-14 15:01:50 +00:00
Roan Kattouw
97a945864a (bug 27328) Redo r82218 properly, expanding URLs with absolute paths 2011-02-19 14:58:16 +00:00
Roan Kattouw
a99d1f47e5 Revert r82218 , doesn't fix absolute path URLs but breaks them. Will fix properly in next commit 2011-02-19 14:46:49 +00:00
Roan Kattouw
94ab016fb2 Followup r82156: skip relative URLs with absolute paths too 2011-02-16 06:27:22 +00:00
Trevor Parscal
64e5faa430 Resolves remaining issues in r82000 with remapping relative CSS URLs that contained queries. 2011-02-15 00:49:34 +00:00
Trevor Parscal
7a1903ec6b Resolves bug #27328 by supporting URL rewriting for CSS that comes from the Wiki, such as user and site scripts. 2011-02-11 22:57:32 +00:00
Trevor Parscal
083125258c Resolves bug #26655 - adds support for space before and after the URL inside the parenthesis of a url() statement in CSS. 2011-01-10 21:31:12 +00:00
Roan Kattouw
b548c98abb (bug 26228) On certain PHP 5.2 installs, finfo functions can be available while FILEINFO_MIME_TYPE is not. Check for the latter explicitly 2010-12-05 13:38:25 +00:00
Roan Kattouw
f21e31ccaa Fix typo in comment 2010-12-03 23:34:12 +00:00
Aaron Schulz
fe9076c3c8 Broke and split up many long lines 2010-12-02 19:49:54 +00:00
Roan Kattouw
1bf567fa6b (bug 25735) Fix regex error in PHP < 5.2.2 by using old (?P<name>) syntax for named subpatterns. Patch by Paul Oranje. 2010-11-01 14:31:32 +00:00
Roan Kattouw
bd02732734 Per r74946 CR, check whether realpath( $file ) returns false before using it 2010-10-18 15:11:48 +00:00
Roan Kattouw
a3d80d71e5 (bug 25546) Feed argument to finfo_file() through readpath() so it'll work on Windows 2010-10-18 14:59:42 +00:00
Trevor Parscal
108fb9b207 Fixed typo in a comment 2010-09-27 18:43:21 +00:00
Alexandre Emsenhuber
95df9b3ed0 Fixed some doxygen warnings 2010-09-23 19:41:29 +00:00
Roan Kattouw
3f535071ff (bug 25182) ResourceLoader breaks because of warnings thrown when an open_basedir is set. Fix is untested, asking reporter to confirm 2010-09-16 13:45:01 +00:00
Trevor Parscal
87c6f7ad2b Made CSSMin::remap take both local and remote directory parameters, allowing more felxible configuration. Also made ResourceLoaderFileModule use $wgScriptPath as the base of the remote directory parameter. 2010-09-11 10:20:26 +00:00
Trevor Parscal
a71f8e3f5f Changed the license to Apache 2.0 - I also hereby grant the copyright to the Wikimedia Foundation. 2010-09-09 22:12:54 +00:00
Trevor Parscal
90c012eaca Using constant to reduce duplication of CSS URL matching regular expression. Adjusted some naming for readability. 2010-09-09 21:57:59 +00:00
Trevor Parscal
546378e5ab Fixes issues with complex background rules containing extra information after the URL, while using quotes within the url. 2010-09-09 21:41:05 +00:00
Trevor Parscal
8e6e2dd1d3 Added 2 more options for mime-type detection. We now detect if the Fileinfo PECL extension is available and use it (PHP 5.3+ will have this more commonly than older versions), then try and use the now deprecated mime_content_type, and finally resort to inferring the mime-type from the file extension. Also, now if all else fails, we will gracefully degrade functionality by not embedding resources with undeterminable mime-types. 2010-09-09 21:34:44 +00:00