Commit 74fcd731 authored by catch's avatar catch
Browse files

Issue #3317745 by heykarthikwithu, mkalkbrenner, catch, smustgrave, Schoenef:...

Issue #3317745 by heykarthikwithu, mkalkbrenner, catch, smustgrave, Schoenef: CSS Aggregation should not rewrite # url

(cherry picked from commit 5f07e3ce)
parent 08cab321
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -90,8 +90,8 @@ protected function processFile($css_asset) {
    // Store base path.
    $this->rewriteFileURIBasePath = $css_base_path . '/';

    // Anchor all paths in the CSS with its base URL, ignoring external and absolute paths.
    return preg_replace_callback('/url\(\s*[\'"]?(?![a-z]+:|\/+)([^\'")]+)[\'"]?\s*\)/i', [$this, 'rewriteFileURI'], $contents);
    // Anchor all paths in the CSS with its base URL, ignoring external and absolute paths and paths starting with '#'.
    return preg_replace_callback('/url\(\s*[\'"]?(?![a-z]+:|\/+|#|%23)([^\'")]+)[\'"]?\s*\)/i', [$this, 'rewriteFileURI'], $contents);
  }

  /**
+12 −0
Original line number Diff line number Diff line
@@ -222,6 +222,18 @@ public function providerTestOptimize() {
        ],
        file_get_contents($absolute_path . 'quotes.css.optimized.css'),
      ],
      [
        [
          'group' => -100,
          'type' => 'file',
          'weight' => 0.013,
          'media' => 'all',
          'preprocess' => TRUE,
          'data' => $path . 'import3.css',
          'basename' => 'import3.css',
        ],
        file_get_contents($absolute_path . 'import3.css.optimized.css'),
      ],
    ];
  }

+6 −0
Original line number Diff line number Diff line
div {
  clip-path: url('#clip-cloud');
}
div {
  clip-path: url('/abc/#clip-cloud');
}
+1 −0
Original line number Diff line number Diff line
div{clip-path:url('#clip-cloud');}div{clip-path:url('/abc/#clip-cloud');}