Hi folks, I found problem with CSS compression.

What are the steps required to reproduce the bug?

Create style with

.element {
   mask: url(#video-mask);
}

This code is valid according to CSS mask

Then enable CSS compression on performance page.

What behavior were you expecting?

See the same result in compressed file:

.element {
   mask: url(#video-mask);
}

What happened instead?

.element {
   mask: url(/themes/custom/THEMENAME/styles/css/#video-mask);
}
CommentFileSizeAuthor
#35 2895258-nr-bot.txt3.72 KBneeds-review-queue-bot
#20 css_mask_workaround-2895258-new-regex-20.patch7.21 KBarmrus
#19 css_mask_workaround-2895258-new-regex-19.patch3.45 KBarmrus
#17 css_mask_workaround-2895258-new-regex.patch2.56 KBNiklan
#15 css_mask_workaround-2895258-UnitTests-15.patch2.56 KBarmrus
#13 2895258-13.patch2.62 KBharsha012
#11 2895258-11.patch2.8 KBharsha012
#9 css_mask_workaround-2895258-UnitTests-8.patch2.56 KBarmrus
#8 css_mask_workaround-2895258-UnitTests-7.patch2.56 KBarmrus
#7 css_mask_workaround_with_unittests-2895258.patch1.81 KBNiklan
#4 css_mask_workaround-2895258-UnitTests-4.patch1.85 KBarmrus
#3 css_mask_workaround-2895258-UnitTests.patch1.82 KBarmrus
#2 css_mask_workaround-2895258.patch725 bytesNiklan
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Niklan created an issue. See original summary.

Niklan’s picture

I've created the patch which fixes this issue.

https://regex101.com/r/fpbnRA/1

I don't sure about url(style.css#test) behavior, which will also ignored.

armrus’s picture

UnitTest changes for this patch.
Dont use this) incorrect descriptions

armrus’s picture

Correct descriptions int unitTest patch (#3)

cilefen’s picture

Component: cache system » asset library system
Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 4: css_mask_workaround-2895258-UnitTests-4.patch, failed testing. View results

Niklan’s picture

armrus’s picture

Fixed test quotes in optimized css file.

harsha012’s picture

Status: Needs work » Needs review
FileSize
2.8 KB

added patch to fix the test

Status: Needs review » Needs work

The last submitted patch, 11: 2895258-11.patch, failed testing. View results

harsha012’s picture

Status: Needs work » Needs review
FileSize
2.62 KB

Status: Needs review » Needs work

The last submitted patch, 13: 2895258-13.patch, failed testing. View results

armrus’s picture

Fixed tests(remove the space from .optimized.css file)

armrus’s picture

Status: Needs work » Needs review
Niklan’s picture

I changed regex to be more flexible.

  • url(style.css); — valid
  • url(../test.css) — valid
  • url(style.css#test) — valid
  • url(#test) — not valid
  • url('#test') — not valid
  • url(../../fonts/fontname.ttf#test) — valid

Not valid variants not will pass to create relative paths.

I found that some fonts using ID's too, but they must have related path, which previous regex can't handle. @armrus can you cover this with UnitTest?

https://regex101.com/r/fpbnRA/2

Niklan’s picture

Status: Needs review » Needs work
armrus’s picture

armrus’s picture

armrus’s picture

Status: Needs work » Needs review

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.

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.

joelpittet’s picture

Status: Needs review » Needs work
Issue tags: +Needs issue summary update

if url(#test) is not valid, what are we fixing here?

Niklan’s picture

That's the point. Currently core regex thinks that url(#test) is valid and pass it to further processing where is bug happens. So url(#test) will convert to url(/themes/custom/THEMENAME/styles/css/#test);, but it still need to be url(#test) after compression is done.

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.

armrus’s picture

Status: Needs work » Needs review
idebr’s picture

This issue touching the same code as #2362643: Drupal alters svg fill paths with base url -> broken svg, but has a slightly different implementation. This issue can possibly be closed as a duplicate?

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

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.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.

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

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should 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.

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

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

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

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

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should 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.

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

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should 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
3.72 KB

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: 9.5.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. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.