[Web] Minor fixes
This commit is contained in:
@@ -685,7 +685,7 @@ class CSS extends Minify
|
||||
protected function extractMath()
|
||||
{
|
||||
$functions = array('calc', 'clamp', 'min', 'max');
|
||||
$pattern = '/('. implode('|', $functions) .')(\(.+?)(?=$|;|})/m';
|
||||
$pattern = '/\b('. implode('|', $functions) .')(\(.+?)(?=$|;|})/m';
|
||||
|
||||
// PHP only supports $this inside anonymous functions since 5.4
|
||||
$minifier = $this;
|
||||
|
@@ -254,7 +254,7 @@ class JS extends Minify
|
||||
// of the RegExp methods (a `\` followed by a variable or value is
|
||||
// likely part of a division, not a regex)
|
||||
$keywords = array('do', 'in', 'new', 'else', 'throw', 'yield', 'delete', 'return', 'typeof');
|
||||
$before = '([=:,;\+\-\*\/\}\(\{\[&\|!]|^|'.implode('|', $keywords).')\s*';
|
||||
$before = '(^|[=:,;\+\-\*\/\}\(\{\[&\|!]|'.implode('|', $keywords).')\s*';
|
||||
$propertiesAndMethods = array(
|
||||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#Properties_2
|
||||
'constructor',
|
||||
|
@@ -105,7 +105,7 @@ abstract class Minify
|
||||
* @param string|string[] $data
|
||||
*
|
||||
* @return static
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public function addFile($data /* $data = null, ... */)
|
||||
@@ -472,7 +472,7 @@ abstract class Minify
|
||||
*/
|
||||
protected function openFileForWriting($path)
|
||||
{
|
||||
if (($handler = @fopen($path, 'w')) === false) {
|
||||
if ($path === '' || ($handler = @fopen($path, 'w')) === false) {
|
||||
throw new IOException('The file "'.$path.'" could not be opened for writing. Check if PHP has enough permissions.');
|
||||
}
|
||||
|
||||
@@ -490,7 +490,11 @@ abstract class Minify
|
||||
*/
|
||||
protected function writeToFile($handler, $content, $path = '')
|
||||
{
|
||||
if (($result = @fwrite($handler, $content)) === false || ($result < strlen($content))) {
|
||||
if (
|
||||
!is_resource($handler) ||
|
||||
($result = @fwrite($handler, $content)) === false ||
|
||||
($result < strlen($content))
|
||||
) {
|
||||
throw new IOException('The file "'.$path.'" could not be written to. Check your disk space and file permissions.');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user