$url = $match['file'][0];
// Skip fully-qualified and protocol-relative URLs and data URIs
- if ( substr( $url, 0, 2 ) === '//' || parse_url( $url, PHP_URL_SCHEME ) ) {
+ // Also skips the rare `behavior` property specifying application's default behavior
+ if (
+ substr( $url, 0, 2 ) === '//' ||
+ parse_url( $url, PHP_URL_SCHEME ) ||
+ substr( $url, 0, 9 ) === '#default#'
+ ) {
break;
}
return self::$mimeTypes[$ext];
}
- $realpath = realpath( $file );
- if (
- $realpath
- && function_exists( 'finfo_file' )
- && function_exists( 'finfo_open' )
- && defined( 'FILEINFO_MIME_TYPE' )
- ) {
- return finfo_file( finfo_open( FILEINFO_MIME_TYPE ), $realpath );
- }
-
- return false;
+ return mime_content_type( realpath( $file ) );
}
/**
// quotation marks (e.g. "foo /* bar").
$comments = [];
- $pattern = '/(?!' . CSSMin::EMBED_REGEX . ')(' . CSSMin::COMMENT_REGEX . ')/s';
+ $pattern = '/(?!' . self::EMBED_REGEX . ')(' . self::COMMENT_REGEX . ')/s';
$source = preg_replace_callback(
$pattern,
}, $source );
// Re-insert comments
- $pattern = '/' . CSSMin::PLACEHOLDER . '(\d+)x/';
+ $pattern = '/' . self::PLACEHOLDER . '(\d+)x/';
$source = preg_replace_callback( $pattern, function ( $match ) use ( &$comments ) {
return $comments[ $match[1] ];
}, $source );
return false;
}
+ /**
+ * @codeCoverageIgnore
+ */
private static function getUrlRegex() {
static $urlRegex;
if ( $urlRegex === null ) {
// Pass thru fully-qualified and protocol-relative URLs and data URIs, as well as local URLs if
// we can't expand them.
- if ( self::isRemoteUrl( $url ) || self::isLocalUrl( $url ) ) {
+ // Also skips the rare `behavior` property specifying application's default behavior
+ if (
+ self::isRemoteUrl( $url ) ||
+ self::isLocalUrl( $url ) ||
+ substr( $url, 0, 9 ) === '#default#'
+ ) {
return $url;
}