Problem/Motivation

SVG CSS using marker-start: url(#some-id); becomes marker-start:url([$css_base_url]#my-id); when aggregated, breaking the CSS style applied to the SVG element. The url() should remain an id selector, unchanged.

This rewrite is problematic for the following SVG CSS properties: marker-start, marker-mid and marker-end.

Proposed resolution

The drupal_build_css_cache() preg_replace_callback needs modified to accommodate marker-start: url(#my-id); CSS properties in aggregated files.

drupal-7.50 /includes/common.inc, Line 3670

       // Anchor all paths in the CSS with its base URL, ignoring external and absolute paths.
        $data .= preg_replace_callback('/url\(\s*[\'"]?(?![a-z]+:|\/+)([^\'")]+)[\'"]?\s*\)/i', '_drupal_build_css_path', $contents);

I'm not going to attempt to modify that regex. ;)

Remaining tasks

  • Needs a patch.
  • Check if issue persists in D8.

Comments

sstedman created an issue. See original summary.

idebr’s picture

Status: Active » Closed (duplicate)
Related issues: +#2362643: Drupal alters svg fill paths with base url -> broken svg

This is being fixed in #2362643: Drupal alters svg fill paths with base url -> broken svg. I'll close this issue as a duplicate, so we can focus our efforts in the related issue.