resourceloader: CSSMin::getLocalFileReferences now strips anchors
[lhc/web/wiklou.git] / includes / libs / CSSMin.php
index 74e8b54..92a4f9e 100644 (file)
@@ -72,15 +72,24 @@ class CSSMin {
                                $url = $match['file'][0];
 
                                // Skip fully-qualified and protocol-relative URLs and data URIs
-                               // 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#'
+                                       parse_url( $url, PHP_URL_SCHEME )
                                ) {
                                        break;
                                }
 
+                               // Strip trailing anchors - T115436
+                               $anchor = strpos( $url, '#' );
+                               if ( $anchor !== false ) {
+                                       $url = substr( $url, 0, $anchor );
+
+                                       // '#some-anchors' is not a file
+                                       if ( $url === '' ) {
+                                               break;
+                                       }
+                               }
+
                                $files[] = $path . $url;
                        }
                }
@@ -485,11 +494,11 @@ class CSSMin {
 
                // Pass thru fully-qualified and protocol-relative URLs and data URIs, as well as local URLs if
                // we can't expand them.
-               // Also skips the rare `behavior` property specifying application's default behavior
+               // Also skips anchors or the rare `behavior` property specifying application's default behavior
                if (
                        self::isRemoteUrl( $url ) ||
                        self::isLocalUrl( $url ) ||
-                       substr( $url, 0, 9 ) === '#default#'
+                       substr( $url, 0, 1 ) === '#'
                ) {
                        return $url;
                }