Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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);
}
Comment | File | Size | Author |
---|---|---|---|
#35 | 2895258-nr-bot.txt | 3.72 KB | needs-review-queue-bot |
#20 | css_mask_workaround-2895258-new-regex-20.patch | 7.21 KB | armrus |
#17 | css_mask_workaround-2895258-new-regex.patch | 2.56 KB | Niklan |
#15 | css_mask_workaround-2895258-UnitTests-15.patch | 2.56 KB | armrus |
#9 | css_mask_workaround-2895258-UnitTests-8.patch | 2.56 KB | armrus |
Comments
Comment #2
NiklanI'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.Comment #3
armrus CreditAttribution: armrus as a volunteer commentedUnitTest changes for this patch.Dont use this) incorrect descriptions
Comment #4
armrus CreditAttribution: armrus as a volunteer commentedCorrect descriptions int unitTest patch (#3)
Comment #5
cilefen CreditAttribution: cilefen commentedComment #7
NiklanComment #8
armrus CreditAttribution: armrus as a volunteer commentedCorrect test (included patch #2 css_mask_workaround-2895258.patch)
Comment #9
armrus CreditAttribution: armrus as a volunteer commentedFixed test quotes in optimized css file.
Comment #10
armrus CreditAttribution: armrus as a volunteer commentedComment #11
harsha012 CreditAttribution: harsha012 as a volunteer and at Red Crackle commentedadded patch to fix the test
Comment #13
harsha012 CreditAttribution: harsha012 as a volunteer and at Red Crackle commentedComment #15
armrus CreditAttribution: armrus as a volunteer commentedFixed tests(remove the space from .optimized.css file)
Comment #16
armrus CreditAttribution: armrus as a volunteer commentedComment #17
NiklanI changed regex to be more flexible.
url(style.css);
— validurl(../test.css)
— validurl(style.css#test)
— validurl(#test)
— not validurl('#test')
— not validurl(../../fonts/fontname.ttf#test)
— validNot 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
Comment #18
NiklanComment #19
armrus CreditAttribution: armrus as a volunteer commentedFiexd unit test and regexp.
Comment #20
armrus CreditAttribution: armrus as a volunteer commentedComment #21
armrus CreditAttribution: armrus as a volunteer commentedComment #24
joelpittetif
url(#test)
is not valid, what are we fixing here?Comment #25
NiklanThat's the point. Currently core regex thinks that
url(#test)
is valid and pass it to further processing where is bug happens. Sourl(#test)
will convert tourl(/themes/custom/THEMENAME/styles/css/#test);
, but it still need to beurl(#test)
after compression is done.Comment #27
armrus CreditAttribution: armrus as a volunteer commentedComment #28
idebr CreditAttribution: idebr at iO commentedThis 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?
Comment #35
needs-review-queue-bot CreditAttribution: needs-review-queue-bot as a volunteer commentedThe 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.