JavaScriptMinifier: Fix "Uninitialized offset" in string and regexp parsing
authorTimo Tijhof <krinklemail@gmail.com>
Wed, 10 Jan 2018 02:02:27 +0000 (02:02 +0000)
committerKrinkle <krinklemail@gmail.com>
Thu, 11 Jan 2018 17:47:59 +0000 (17:47 +0000)
commitf2ef535e3959372dd84f527cb7d45600c56c93a9
tree0c25ce7a3c8d0ddb4d7a1b788bf7ddd7967b02d2
parentbd8f8ca29d0c2813e5f97d7b326d94dde91a9dba
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
includes/libs/JavaScriptMinifier.php
tests/phpunit/includes/libs/JavaScriptMinifierTest.php