Problem/Motivation

When CSS aggregation is enabled and SVG is imported in css with a fragment URL i.e. # or %23 eg: background: url(#SVGID_1_);

Here, url(#SVGID_1_) gets converted to url(http://domain.com/path/path/#SVGID_1_1) resulting in a broken SVG.

Steps to reproduce

Enable CSS aggregation from /admin/config/development/performance

Use an SVG with a fragment URL. eg: background: url(#SVGID_1_);

Proposed resolution

Ignore fragment URL when building and returning the path of the aggregated stylesheets.

Remaining tasks

Review

Commit

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet

None

CommentFileSizeAuthor
#98 2362643-98.patch13.35 KB_utsavsharma
#98 interdiff_d10.txt13.35 KB_utsavsharma
#96 drupal-10.0.10-fix_broken_svg-2362643-96.patch13.31 KBwsantell
#94 2362643-nr-bot.txt150 bytesneeds-review-queue-bot
#82 drupal-9.3.x-fix_broken_svg-2362643-81.patch14.34 KBhswong3i
#76 interdiff_72-76.txt12.48 KBraman.b
#76 2362643-76.patch12.75 KBraman.b
#72 interdiff_63-72.txt1.31 KBraman.b
#72 2362643-72.patch12.74 KBraman.b
#63 2362643-63.patch12.74 KBacbramley
#63 2362643-63-TEST-ONLY.patch10.18 KBacbramley
#63 interdiff-2362643-47-63.txt2.54 KBacbramley
#47 2362643-47-fix-svg.patch11.97 KBmbrc
#41 2362643-41-fix-svg.patch12.1 KBPls
#37 2362643-37-fix-svg-D7.patch2.27 KBericclaeren
#30 interdiff-2362643-28-30.txt2.28 KBparkecag
#30 2362643-30-fix-svg.patch2.66 KBparkecag
#28 2362643-28-fix-svg.patch2.62 KBparkecag
#23 advagg-2362643-21-fix-svg.patch7.96 KBmikeytown2
#18 drupal-2362643-18-fix-css-SVG-url-D7.patch2.23 KBmikeytown2
#17 drupal-2362643-17-fix-css-SVG-url-D8.patch2.46 KBmikeytown2
#11 advagg-2362643-10-fix-url-svg.patch1.7 KBmikeytown2
#2 gradient.svg_.zip862 bytesGijsRoge

Issue fork drupal-2362643

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

GijsRoge’s picture

Issue summary: View changes
GijsRoge’s picture

Issue summary: View changes
FileSize
862 bytes
mikeytown2’s picture

Does this broken svg issue happen when advagg is disabled but core aggregation is enabled?

GijsRoge’s picture

Yes, I noticed yesterday it doesn't have anything to do with advagg. (Icouldn't update my post anymore because of the anti-spam protection)

I'll move it.

GijsRoge’s picture

Title: Fix improperly set type on svg path » Drupal alter's svg fill path's with base url -> broken svg
Project: Advanced CSS/JS Aggregation » Drupal core
Version: 7.x-2.x-dev » 9.x-dev
Component: Code » ajax system
mikeytown2’s picture

Version: 9.x-dev » 7.x-dev
Component: ajax system » CSS

It is a core issue, but it cam be fixed in advagg. We'll need to fix in advagg, then 7.x so it can be tested then see if 8.x needs the fix and then fix it there so it can be committed in 7.x. Long story short it will be fixed in advagg before it's fixed in core.

GijsRoge’s picture

Alright, thats good news. Thanks!

mikeytown2’s picture

Project: Drupal core » Advanced Aggregator
Version: 7.x-dev »
Component: CSS » Code

Moving this back to AdvAgg; will then move to core once it's fixed here. Will also ping the CDN module as this will likely be an issue there as well.

Code in AdvAgg: _advagg_build_css_path()

Related issues
#1514182: IE @font-face CSS hack URL broken by CDN module's overridden CSS aggregation
#1961340: CSS aggregation breaks file URL rewriting because it abuses it

mikeytown2’s picture

Project: Advanced Aggregator » Advanced CSS/JS Aggregation
Version: » 7.x-2.x-dev

  • mikeytown2 committed 5f5b5dd on
    Issue #2362643 by mikeytown2: Do not parse SVG urls in CSS for base path...
mikeytown2’s picture

Status: Active » Fixed
FileSize
1.7 KB

Committed this patch; I edited the regex so that URL's that start with # do not get altered.

GijsRoge’s picture

Brilliant, thanks!

Issue is still present after applying the patch, rebuilding aggregates and clearing cache

output
<path xmlns="http://www.w3.org/2000/svg" fill="url(/sites/all/themes/elipse/css/#a)" d="M1256.4 386h1500v21h-1500v-21z"/>
Should be
<path xmlns="http://www.w3.org/2000/svg" fill="url(#a)" d="M1256.4 386h1500v21h-1500v-21z"/>

GijsRoge’s picture

Status: Fixed » Needs work
mikeytown2’s picture

Status: Needs work » Postponed (maintainer needs more info)

Can I get the full context in how this svg is used. I was thinking it was inside a css file.

This is the test code with the assumption that url(#a) is inside a css file.

$contents = '<path xmlns="http://www.w3.org/2000/svg" fill="url(#a)" d="M1256.4 386h1500v21h-1500v-21z"/>';
$css_base_url = 'BASE-PATH';

module_load_include('inc', 'advagg', 'advagg');
_advagg_build_css_path(NULL, $css_base_url . '/');

// Anchor all paths in the CSS with its base URL, ignoring external,
// absolute paths, and urls that start with # (SVG).
$contents = preg_replace_callback('/url\(\s*[\'"]?(?![a-z]+:|\/+|\#+)([^\'")]+)[\'"]?\s*\)/i', '_advagg_build_css_path', $contents);
echo 'New code: ' . htmlentities($contents, TRUE) . "<br>\n";
$contents = preg_replace_callback('/url\(\s*[\'"]?(?![a-z]+:|\/+)([^\'")]+)[\'"]?\s*\)/i', '_advagg_build_css_path', $contents);
echo 'Old code: ' . htmlentities($contents, TRUE) . "<br>\n";

Output:

New code: <path xmlns="http://www.w3.org/2000/svg" fill="url(#a)" d="M1256.4 386h1500v21h-1500v-21z"/>
Old code: <path xmlns="http://www.w3.org/2000/svg" fill="url(//localhost/d7/BASE-PATH/#a)" d="M1256.4 386h1500v21h-1500v-21z"/>
GijsRoge’s picture

Its used inside a css file within data-url(''); (so perhaps you could just ignore everything inside a data url as they do not have to contain relative paths) wich is a more elegant way of fixing this problem perhaps.

And your new code output seems to be correct.

This is the result of the applied patch http://take.ms/5R0TC (seems to be correct, so its weird that it works for you but not for me)
I have the exact same use case as you described in the post above.

Is it possible that this fill="url('#SVGID_1_')" (notice the single quotes inside) causes the regex to fail?

mikeytown2’s picture

Single/double or no quotes doesn't affect the regex matching from my testing. url('data: gets ignored because the regex skips all strings inside of url that start with {scheme}: ([a-z]+:), slashes (\/+) and now the number sign (\#+).

I still can't repo the bug since I committed the patch in #11. If you're worried about posting the full CSS code here that contains the SVG, you can use my contact info to point me toward the file so I can fix the bug.

mikeytown2’s picture

Project: Advanced CSS/JS Aggregation » Drupal core
Version: 7.x-2.x-dev » 8.0.x-dev
Component: Code » CSS
Status: Postponed (maintainer needs more info) » Needs review
FileSize
2.46 KB

Moving this to core.
Following patch should fix SVG issues in D8 css.

mikeytown2’s picture

Version: 8.0.x-dev » 7.x-dev
FileSize
2.23 KB

7.x patch

mikeytown2’s picture

Version: 7.x-dev » 8.0.x-dev

7.x & 8.0.x pass; moving to D8 for core inclusion.

@GijsRoge
Try applying the D7 patch in #18; that might fix it for you.

GijsRoge’s picture

@Mikeytown2 Issue still exists after patch from post #18

Link to the full css file -> https://dl.dropboxusercontent.com/u/15198233/main.css ( line: 859 )

mikeytown2’s picture

Project: Drupal core » Advanced CSS/JS Aggregation
Version: 8.0.x-dev » 7.x-2.x-dev
Component: CSS » Code

found it!

%23 is also #. Will need to adjust the regex to account for this and write a test as well.

/* line 53, /Applications/MAMP/htdocs/elipse/htdocs/sites/all/themes/elipse/scss/svg/icons.data.svg */
.icon-gradient, .frontbanner:after {
  background-image: url('data:image/svg+xml;charset=US-ASCII,%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22utf-8%22%3F%3E%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%221500%22%20height%3D%2221%22%20viewBox%3D%22793.4%200%201500%2021%22%20enable-background%3D%22new%20793.4%200%201500%2021%22%3E%3Cg%20id%3D%22Layer_1_1_%22%3E%3ClinearGradient%20id%3D%22SVGID_1_%22%20gradientUnits%3D%22userSpaceOnUse%22%20x1%3D%225037.169%22%20y1%3D%2219.555%22%20x2%3D%225038.169%22%20y2%3D%2219.555%22%20gradientTransform%3D%22matrix(1500%200%200%20-538%20-7554960%2010531)%22%3E%3Cstop%20offset%3D%220%22%20stop-color%3D%22%23F5F8F8%22%2F%3E%3Cstop%20offset%3D%22.355%22%20stop-color%3D%22%23FAFBFB%22%20stop-opacity%3D%22.98%22%2F%3E%3Cstop%20offset%3D%22.833%22%20stop-color%3D%22%23FCFCFC%22%20stop-opacity%3D%220%22%2F%3E%3Cstop%20offset%3D%221%22%20stop-color%3D%22%23fff%22%20stop-opacity%3D%220%22%2F%3E%3C%2FlinearGradient%3E%3Cpath%20fill%3D%22url(%23SVGID_1_)%22%20d%3D%22M793.4%200h1500v21h-1500V0z%22%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E');
  background-repeat: no-repeat; }

  • mikeytown2 committed c84270d on 7.x-2.x
    Issue #2362643 by mikeytown2: Test SVG & fix for %23 in url().
    
mikeytown2’s picture

Project: Advanced CSS/JS Aggregation » Drupal core
Version: 7.x-2.x-dev » 8.0.x-dev
Component: Code » CSS
Status: Needs review » Needs work
FileSize
7.96 KB

Committed to AdvAgg. moving back to core.

Chernous_dn’s picture

Status: Needs work » Needs review

The last submitted patch, 11: advagg-2362643-10-fix-url-svg.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 23: advagg-2362643-21-fix-svg.patch, failed testing.

kevinquillen’s picture

Can confirm this is a bug. Here is the CSS on an SVG element:

   url: (#diagonal-up);

Without core aggregation of CSS enabled, it works fine. When I enable it, it tacks a URL on to the beginning #diagonal-up, breaking it.

The patch in #17 worked for me.

parkecag’s picture

Status: Needs work » Needs review
FileSize
2.62 KB

Posting a re-roll of patch from #17.

RainbowArray’s picture

Status: Needs review » Needs work

We will need to update this patch to include the check for %23 that was noted in #21.

parkecag’s picture

Status: Needs work » Needs review
FileSize
2.66 KB
2.28 KB

New patch that checks for %23 also.

RainbowArray’s picture

Status: Needs review » Reviewed & tested by the community

Reviewed the patch and tested it, appears to work. Great work parkecag!

Wim Leers’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

This needs test coverage, to prevent this from regressing again in the future.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

ericclaeren’s picture

Version: 8.1.x-dev » 7.x-dev

The patch in #2362643-18: Drupal alters svg fill paths with base url -> broken svg didn't work for me, the updated D8 regex into D7 did, will try to create an updated patch asap.

Wim Leers’s picture

Version: 7.x-dev » 8.1.x-dev

Why did you change the version? This needs to be fixed in Drupal 8 first.

ericclaeren’s picture

Excuse me, didn't do that on purpose. Thought it was for my reply only.

I've attached a patch for Drupal 7 based on the fix in #2362643-30: Drupal alters svg fill paths with base url -> broken svg

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Pls’s picture

#30 patch works great for Drupal 8.2.3. Would love to push and get this in core, as this is pretty major for specific use cases, where svg is used.

@Wim Leers, I would love to create missing tests here. But I need more info how they should be properly created. Have not much experience with writing core tests really, but want to learn. Thanks :)

Wim Leers’s picture

@Pls: Thanks for taking this on! Here's some guidance for you:

  1. +++ b/core/lib/Drupal/Core/Asset/CssOptimizer.php
    @@ -71,8 +71,9 @@ protected function processFile($css_asset) {
    -    // 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', array($this, 'rewriteFileURI'), $contents);
    +    // Anchor all paths in the CSS with its base URL, ignoring external,
    +    // absolute, and SVG (# or %23) paths.
    +    return preg_replace_callback('/url\(\s*[\'"]?(?![a-z]+:|\/+|\#|\%23+)([^\'")]+)[\'"]?\s*\)/i', array($this, 'rewriteFileURI'), $contents);
    
    @@ -176,9 +177,10 @@ protected function loadNestedFile($matches) {
    -    // Alter all internal url() paths. Leave external paths alone. We don't need
    -    // to normalize absolute paths here because that will be done later.
    -    return preg_replace('/url\(\s*([\'"]?)(?![a-z]+:|\/+)([^\'")]+)([\'"]?)\s*\)/i', 'url(\1' . $directory . '\2\3)', $file);
    +    // Alter all internal _url() paths. Leave external paths alone. We don't need
    +    // to normalize absolute paths here because that will be done later. Also
    +    // ignore SVG paths (# or %23).
    +    return preg_replace('/url\(\s*([\'"]?)(?![a-z]+:|\/+|\#|\%23+)([^\'")]+)([\'"]?)\s*\)/i', 'url(\1' . $directory . '\2\3)', $file);
    

    These changes can be tested by expanding the test coverage in \Drupal\Tests\Core\Asset\CssOptimizerUnitTest.

    Plenty of examples to look at.

  2. +++ b/core/modules/color/color.module
    @@ -473,8 +473,9 @@ function color_scheme_form_submit($form, FormStateInterface $form_state) {
    -      // Prefix all paths within this CSS file, ignoring absolute paths.
    -      $style = preg_replace_callback('/url\([\'"]?(?![a-z]+:|\/+)([^\'")]+)[\'"]?\)/i', array($css_optimizer, 'rewriteFileURI'), $style);
    +      // Prefix all paths within this CSS file, ignoring external, absolute, and
    +      // SVG paths (# or %23).
    +      $style = preg_replace_callback('/url\([\'"]?(?![a-z]+:|\/+|\#|\%23+)([^\'")]+)[\'"]?\)/i', array($css_optimizer, 'rewriteFileURI'), $style);
    

    Testing this one is going to be a bit more difficult.

    But I think you should be able to expand the test coverage in \Drupal\Tests\color\Functional\ColorTest::_testColor() :)

Pls’s picture

@Wim Leers: Thanks for your pointers, really helped me starting up, appreciate your help!

Added patch with test dummy data added for CssOptimizerUnitTest. Let me know what you think.

Haven't figured out how to write tests for Color module. It looks like it compares whole stylesheet with test data from first look. Do you guys have any ideas or suggestions how to implement this better? :)

Pls’s picture

Status: Needs work » Needs review

The last submitted patch, 37: 2362643-37-fix-svg-D7.patch, failed testing.

Wim Leers’s picture

#41 looks great :)

Haven't figured out how to write tests for Color module. It looks like it compares whole stylesheet with test data from first look. Do you guys have any ideas or suggestions how to implement this better? :)

No, not without refactoring all of its test coverage. I'd just continue the existing way of testing: use $this->assertTrue(strpos(… or $this->assertPattern(….

Wim Leers’s picture

Status: Needs review » Needs work

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

mbrc’s picture

Same patch as #41, but applies to 8.3. Still needs additional tests.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

kala4ek’s picture

#47 works perfectly for me
:+1::skin-tone-2:

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Rob230’s picture

#47 is working great for me. What do we need to get this fix in core?

johnny5th’s picture

#47 fixed my issue!

idebr’s picture

idebr’s picture

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

jcsparks’s picture

Testing with Drupal 8.6.0 - #47 still works for me. How do we get this rolled into core?

andypost’s picture

kala4ek’s picture

Status: Needs work » Reviewed & tested by the community

Just checked, #47 perfectly applies to current 8.7.x.
According to the latest comments, mark it is rtbc.

andypost’s picture

Issue tags: -Needs tests
alexpott’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/lib/Drupal/Core/Asset/CssOptimizer.php
    @@ -60,8 +60,9 @@ protected function processFile($css_asset) {
    +    // absolute, and SVG (# or %23) paths.
    

    Is it an SVG path? I think we should use the language from CSS documentation. These appear to be fragment URLs. See https://drafts.csswg.org/css-values-3/#local-urls

    Going down that path I think we also have a few more bugs here because we should not prefix the idents inherit, initial and unset - let's open a follow-up for that.

  2. +++ b/core/lib/Drupal/Core/Asset/CssOptimizer.php
    @@ -60,8 +60,9 @@ protected function processFile($css_asset) {
    +    return preg_replace_callback('/url\(\s*[\'"]?(?![a-z]+:|\/+|\#|\%23+)([^\'")]+)[\'"]?\s*\)/i', [$this, 'rewriteFileURI'], $contents);
    
    @@ -166,8 +167,9 @@ protected function loadNestedFile($matches) {
    +    return preg_replace('/url\(\s*([\'"]?)(?![a-z]+:|\/+|\#|\%23+)([^\'")]+)([\'"]?)\s*\)/i', 'url(\1' . $directory . '\2\3)', $file);
    
    +++ b/core/modules/color/color.module
    @@ -488,8 +488,9 @@ function color_scheme_form_submit($form, FormStateInterface $form_state) {
    +      $style = preg_replace_callback('/url\([\'"]?(?![a-z]+:|\/+|\#|\%23+)([^\'")]+)[\'"]?\)/i', [$css_optimizer, 'rewriteFileURI'], $style);
    

    Why are we doing %23 as well? This is not tested. We need to add test coverage if this is necessary.

bendev’s picture

tested #47 successfully.
Thanks for the patch !

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

acbramley’s picture

Why are we doing %23 as well? This is not tested. We need to add test coverage if this is necessary.

This is to catch any paths using the HTML encoded version of "#someID". It is tested in the .url .inline-svg definition with:

....url(%23SVGID_1_)....

It's a bit hard to see but it's in there ;)

This patch fixes #60.1. Also adding a test only patch.

Opened #3077821: [PP-1] Do not prefix the idents inherit, initial and unset during CSS optimisation as a follow up as per #60

The last submitted patch, 63: 2362643-63-TEST-ONLY.patch, failed testing. View results

Guietc’s picture

The patch #63 works great. Thanks.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

RaphaelBriskie’s picture

Status: Needs review » Reviewed & tested by the community

Can confirm this patch works to fix this issue.

The last submitted patch, 63: 2362643-63-TEST-ONLY.patch, failed testing. View results

quietone’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Bug Smash Initiative, +Needs issue summary update

Reviewing RTBC for Bug Smash Initiative, thus adding tag.

The first thing I notice is that the issue summary is an explanation of the problem and nothing about the proposed resolution. Of course, it is kind of implied, that we don't want to have broken svg. Still it would be helpful to include how one is going to fix the problem in the IS.

Reading the patch there are two references to this issue, neither with the usual format of 'See https...'. I wonder if pointing to this issue is necessary. Why not just expand the comment to say what it is doing to keep the url correct? Keep in mind, this is an area I know little about so I could be way off the track here.

  1. +++ b/core/tests/Drupal/Tests/Core/Asset/CssOptimizerUnitTest.php
    @@ -61,6 +61,8 @@ public function providerTestOptimize() {
    +      //   (https://www.drupal.org/project/drupal/issues/2362643)
    

    Should this be 'See https://www.drupal.org/project/drupal/issues/2362643' or an expanded comment?

  2. +++ b/core/tests/Drupal/Tests/Core/Asset/css_test_files/import1.css
    @@ -18,3 +18,33 @@ ul, select {
    +/* Test urls with # or %23 character - https://www.drupal.org/node/2362643 */
    

    Again, same as above

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

raman.b’s picture

Issue summary: View changes
Status: Needs work » Needs review
FileSize
12.74 KB
1.31 KB

Applying IS template

raman.b’s picture

Ruuds’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, the patch of #72 works great, even on 8.9.11.

lauriii’s picture

Status: Reviewed & tested by the community » Needs work

There are some failures in the CI run for #72.

raman.b’s picture

Status: Needs work » Needs review
FileSize
12.75 KB
12.48 KB

Fixing CI failures

W01F’s picture

Would it be possible to backport this patch to be compatible with D8? I have a number of sites with this issue and haven't yet made the leap to get the sites upgraded to D9 >< - even though I know it's supposed to be a small leap!

aspilicious’s picture

Status: Needs review » Reviewed & tested by the community

Works great all the comments are adressed

Ruuds’s picture

Thanks, still works great for me too!

larowlan’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

Back in #40 Wim asked for tests for the color module changes, but they seemed to have slipped through, i.e. we're missing coverage for those changes.

Needs work for that

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

hswong3i’s picture

Patch re-roll via 9.3.x-dev, also works with 9.2.8.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

agoradesign’s picture

#82 works for me :)

b_sharpe’s picture

Status: Needs review » Needs work

Although this appears to fix references such as url(#someSVG);, I'm finding it is breaking inline SVGs by removing spaces.

Pre-patch:

data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='2' fill='%23fff'/%3e%3c/svg%3e

Post-patch:

data:image/svg+xml,%3csvgxmlns='http://www.w3.org/2000/svg'viewBox='-4-488'%3e%3ccircler='2'fill='%23fff'/%3e%3c/svg%3e
b_sharpe’s picture

Status: Needs work » Needs review
W01F’s picture

I can also confirm the latest #82 patch is working on latest 9.3.12 with both core and advagg aggregation enabled.

malcomio’s picture

I was encountering the clip-path issue described in #2994490: CssOptimizer doesn't handle SVG clipPath urls properly, and the patch in #82 fixes that for me.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

tdnshah’s picture

I was facing the issue with clip-path with the core version 9.4.5 and #82 fixes that for me.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
FileSize
150 bytes

The Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

wsantell’s picture

The patch for #81 fails due to Color being removed from Core. The attached patch is a rewrite of #81 with the color.module patch removed. It works against the 10.0.10 branch; not tested against 10.1.x

xaa’s picture

hi, #96 doesn't seems apply on 10.1.x

_utsavsharma’s picture

xaa’s picture

Awesome, thank you! Patch is working on 10.1.x using php 8.1

djsagar changed the visibility of the branch 2362643-drupal-alters-svg to hidden.

mstrelan’s picture

Title: Drupal alter's svg fill path's with base url -> broken svg » Drupal alters svg fill paths with base url -> broken svg