Commit graph

29 commits

Author SHA1 Message Date
Timo Tijhof
3316a00c26 JavaScriptMinifier: Fix "Uninitialized offset" in regexp char class parsing
Bug: T75556
Change-Id: I0bb63212dd44aec3c6b40477553dbf6a471bc7b3
2018-01-30 19:55:15 -08:00
Timo Tijhof
da786f6ae5 JavaScriptMinifier: Remove support for unused $maxLineLength param
Follows-up 93b8023946.

The $wgResourceLoaderMinifierMaxLineLength config var was deprecated
in MediaWiki 1.27. The parameter of minify() was not used by other
code, and no new usage has been introduced since then, either.

Remove the feature from JavaScriptMinifier, and add a release note.
The 1.31 release notes already contain a note about the removal
of the configuration variables.

The feature was not covered by unit tests.

Change-Id: I38eb4187e3a8e2d882f317481b43f0bf6ac3bada
2018-01-11 22:59:47 +00:00
Timo Tijhof
d43cbc7ca9 JavaScriptMinifier: Enable phpcs and fix violations
Found 90 violations. 88 fixed by phpxbf. 2 remaining violations
were Generic.Files.LineLength.TooLong (fixed manually).

Change-Id: I760acc5b249fe6f4863652de7b563eaa5f13f05f
2018-01-11 22:21:53 +00:00
Timo Tijhof
f2ef535e39 JavaScriptMinifier: Fix "Uninitialized offset" in string and regexp parsing
When parsing an incomplete string literal or regex literal at the end of a file,
$end would be set to an offset higher than $length, because the code
speculatively increases $end without correcting for this scenario.

This is due to the assumption that the strcspn() search will end because
an end character was seen, instead of simply ending because the string
doesn't have any further characters.

Bug: T75556
Change-Id: I2325c9aff33293c13ff414699c2d47306182aaa6
2018-01-11 17:47:59 +00:00
Timo Tijhof
bd8f8ca29d JavaScriptMinifier: Improve docs for parsing of string literals
Also update docs for parsing of regexp literals to match.

Bug: T75556
Change-Id: I86c79b1b1866339d65d1c69e56d457c62544aaac
2018-01-11 17:46:31 +00:00
Umherirrender
255d76f2a1 build: Updating mediawiki/mediawiki-codesniffer to 15.0.0
Clean up use of @codingStandardsIgnore
- @codingStandardsIgnoreFile -> phpcs:ignoreFile
- @codingStandardsIgnoreLine -> phpcs:ignore
- @codingStandardsIgnoreStart -> phpcs:disable
- @codingStandardsIgnoreEnd -> phpcs:enable

For phpcs:disable always the necessary sniffs are provided.
Some start/end pairs are changed to line ignore

Change-Id: I92ef235849bcc349c69e53504e664a155dd162c8
2018-01-01 14:10:16 +01:00
Thiemo Mättig
544122a6c2 Remove self-explaining "section heading" comments from classes
I can see that "parent::__construct" literally calls the parent
constructor. I can see that stuff preceeded by the keyword "protected"
is protected. I really (really) don't need comments explaining such.

Change-Id: I7458e714976a6acd3ba6a7c93fdc27d03903df83
2017-12-28 16:12:08 +01:00
Timo Tijhof
37de322d73 JavaScriptMinifier: Improve docs around parsing of regexp literals
Bug: T75556
Change-Id: Ifcb6bc21418dfc2e1d3e44dbd2497a0f5f691bf3
2017-12-24 21:48:34 +00:00
Timo Tijhof
93b8023946 JavaScriptMinifier: Remove support for unused $statementsOnOwnLine flag
The $wgResourceLoaderMinifierStatementsOnOwnLine config var was deprecated
in MediaWiki 1.27. The parameter of minify() was not used by other code, and
no new usage has been introduced since then, either.

Remove the feature from JavaScriptMinifier, and add a release note for that.
The same 1.31 release notes also contain a note already about the removal
of the configuration variable.

The feature was not covered by unit tests.

The following private variables have been removed, that are no longer used
due to this change: $newlineBefore, $newlineAfter, $newlineAdded.

Change-Id: I2cbf271156c1954abb982531d0125b4b9573b12c
2017-12-22 18:38:04 +00:00
Ori Livneh
3ecec5434e Only convert boolean true/false to !0/!1
Fix-up for I5ab29b686b8. If we encounter stupid code like
`a.true = 1;` or `a = { true: 1 }`, we should not convert that to !0/!1.
Because JSMin barfs on such input, it is necessary to add another parameter to
the test method which specifies whether or not the minified JavaScript is
supposed to be valid JavaScript by the standards of JSMin.

Change-Id: Ib78c628147fdb95982d6e33e0ab298584fb63d0b
2015-08-15 14:13:59 -07:00
Ori Livneh
a44fe77c62 JavaScriptMinifier: minify booleans
Minify true to !0 and false to !1, like Google Closure Compiler and UglifyJS2.

Change-Id: I5ab29b686b812d64a2913611be091084c06d630b
2015-08-14 17:51:59 +00:00
Siebrand Mazeland
c0c39640e4 Make phpcs-strict pass on includes/ (5/~10)
Change-Id: I259f3f11cfc22f3ed1693f9ebd5bd80491b8a6e8
2014-05-11 19:35:32 +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
umherirrender
c157f4d424 Remove a bunch of trailing spaces and unneeded newlines
Change-Id: I52ae3c55044bc8c53698e356bad74969406670bf
2012-10-20 13:32:35 +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
Brion Vibber
e97346ec18 Revert r103978, r103979 -- screwed something up, breaks jQuery minification.
Incremented ResourceLoader::filterCacheVersion rather than decrementing to avoid potential confusion, especially since we already needed the incr.
2011-11-23 00:22:46 +00:00
Brion Vibber
956de0db3f Functional part of r103978 (d'oh!) plus an update to the ResourceLoader filter cache key, so broken entries stuck in cache will be reloaded. 2011-11-22 23:20:50 +00:00
Platonides
a82a7940f6 Final fixup to r103910 and follow-ups.
Reverts r103931 test change.
2011-11-22 18:56:55 +00:00
Platonides
6cac97e88c Two decimal points may be valid, as 5..toString() == (5.).toString()
Added some tests
2011-11-22 18:42:21 +00:00
Platonides
b23dc2f758 Follow-up r103915: We need to increment $end before the strcspn.
Adjusting the tests, since it is now adding the newline after the number.
2011-11-22 18:10:25 +00:00
Platonides
7b9e098668 Follow-up r103915. The @fixme of r103865 was wrong.
It is apparently legal to have a decimal point without after it, 
eg. var a = 5.
Not for hexadecimal numbers.
2011-11-22 17:48:32 +00:00
Platonides
4417d4cfbe Fix r103865 fixmes about case where there a parse error should be raised.
Also detect as an error 1..0 or 1eeeeee5
2011-11-22 16:21:18 +00:00
Platonides
f0e8973335 Follow-up r103865. Accept lowercase hex and remove empty statement. 2011-11-22 16:04:39 +00:00
Brion Vibber
3e415f816f * (bug 32548) fix minification bug when numeric literal with exponent was split over lines
This broke the OpenLayers support in the Maps extension, as used for example on TranslateWiki.net.
The original JavaScriptMinifier's tokenizer (r83885) explicitly didn't bother looking for the exponent part because it "didn't matter" to its internal state machine; however since r83891 added a max line length that definitely is not true.

I've split out handling of hex and decimal numerals, and let the decimal numeral handling check for exponents.

PHPUnit test cases were added in r103846.
2011-11-21 23:16:36 +00:00
Neil Kandalgaonkar
388d13ce42 removing another use of the vertical tab & form feed escapes, which are not available in production php5.2.4 2011-03-15 04:41:15 +00:00
Neil Kandalgaonkar
50a412b7d3 the vertical tab \v and form feed \f escapes are not available in php5.2.4 which is what we run in production. Using equivalent hexadecimal 2011-03-15 04:37:06 +00:00
Roan Kattouw
27508f06af Followup r83891: don't insert a newline before ++ or -- . Patch by Paul Copperman 2011-03-14 18:04:39 +00:00
Roan Kattouw
47d5ad564b Followup r83885: implement maximum line length and statement termination (each statement on its own line) in JavaScriptMinifier. Also add globals for these things and update minify.php for these new config vars. 2011-03-14 13:24:30 +00:00
Roan Kattouw
867fc1cba8 (bug 27528) Incorporate Paul Copperman's minifier 2011-03-14 11:44:33 +00:00