ResourceLoaderImageModule: Use CSSMin::buildUrlValue() where needed
authorRoan Kattouw <roan.kattouw@gmail.com>
Wed, 13 Sep 2017 19:26:05 +0000 (12:26 -0700)
committerRoan Kattouw <roan.kattouw@gmail.com>
Thu, 14 Sep 2017 18:40:02 +0000 (11:40 -0700)
We can't just assume that the URLs that we generate are safe to use
in url() without quotes. There's already a function that automatically
uses quotes where necessary, so use that.

Change-Id: I6663e49b82592eb45b8854fcff56ac966b39f8ce

includes/resourceloader/ResourceLoaderImageModule.php

index cbcf5a0..8b54959 100644 (file)
@@ -381,11 +381,13 @@ class ResourceLoaderImageModule extends ResourceLoaderModule {
         * @return string[] CSS declarations to use given URIs as background-image
         */
        protected function getCssDeclarations( $primary, $fallback ) {
+               $primaryUrl = CSSMin::buildUrlValue( $primary );
+               $fallbackUrl = CSSMin::buildUrlValue( $fallback );
                return [
-                       "background-image: url($fallback);",
-                       "background-image: linear-gradient(transparent, transparent), url($primary);",
+                       "background-image: $fallbackUrl;",
+                       "background-image: linear-gradient(transparent, transparent), $primaryUrl;",
                        // Do not serve SVG to Opera 12, bad rendering with border-radius or background-size (T87504)
-                       "background-image: -o-linear-gradient(transparent, transparent), url($fallback);",
+                       "background-image: -o-linear-gradient(transparent, transparent), $fallbackUrl;",
                ];
        }