We ran into a bug where @import CSS directives that contained protocol-relative paths would be somehow stripped before they made it into production's copy of the CSS. I tracked down the bug to a problem in the drupal_load_stylesheet_content regexp's exclusion of external content, and a patch to correct the problem is attached.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

hlieberman’s picture

Made an error with the previous patch. My fault!

hlieberman’s picture

Uploading the same (broken) patch is not helpful.

dawehner’s picture

Issue tags: +Needs tests

Adding a tag.

hlieberman’s picture

New patch including unit test.

Wim Leers’s picture

Title: Drupal CSS Caching and Aggregation breaks protocol-relative paths » Drupal CSS preprocessing breaks protocol-relative paths
Component: cache system » base system
FileSize
3.54 KB
Wim Leers’s picture

nod_’s picture

Status: Needs review » Reviewed & tested by the community

looks ok to me.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

I've apply the patch and reverted the change to core/lib/Drupal/Core/Asset/CssOptimizer.php and the tests fail. With they pass. Nice fix. In future it's nice to post a will fail patch that only contains the changes to the tests - so that we can confirm that we've fixed the issue and won't break it again.

Committed 4431c7e and pushed to 8.x. Thanks!

Wim Leers’s picture

Issue tags: +CSS aggregation

Alex: sorry, will do!

Automatically closed -- issue fixed for 2 weeks with no activity.

bradjones1’s picture

Issue summary: View changes
Status: Closed (fixed) » Patch (to be ported)
Issue tags: +Needs backport to D7, +Needs backport to D6
bradjones1’s picture

Version: 8.x-dev » 7.x-dev
Status: Patch (to be ported) » Needs review
FileSize
692 bytes

Here's a backport to D7. I don't believe this has a test in D7; can someone verify this?

mgifford’s picture

There are no tests in @bradjones1's patch. Are they needed for this backport? If so we can at least tag it as "Needs tests".

What testing is required to get this into D7? The preg_replace_callback expression is the same as what got into D8, so that should be fine.

dcam’s picture

Status: Needs review » Reviewed & tested by the community

Since I can't assign this to David_Rothstein I'm going to go ahead and set the status to RTBC so he'll see it.

The change in #12 to the regex string is the same as what went into D8, but as far as I can tell the D8 tests which were modified don't exist in D7. They're CSS optimization tests. I'm not sure if they're part of some other issue waiting to be backported. I couldn't find them if they are. Do we need to find some way to backport everything in the D8 patch? If not, then #12 is RTBC.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 12: css_dont_import_protocol_relative-2014851-12.patch, failed testing.

Status: Needs work » Needs review
markhalliwell’s picture

Sorry, but this is a really major bug; one that cannot be fixed in contrib (AdvAgg still ultimately goes through core's aggregation if bundling/grouping is relatively simple enough). It's very common practice to add an @import statement for your theme's font, say from Google, at the top. I'm surprised I haven't noticed this before :-/ Regardless, here's the backported tests.

helmo’s picture

Status: Needs review » Reviewed & tested by the community

Works as expected!

Thanks.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 17: drupal_css-2014851-17.patch, failed testing.

Status: Needs work » Needs review

dcam queued 17: drupal_css-2014851-17.patch for re-testing.

dcam’s picture

Status: Needs review » Reviewed & tested by the community
Arlina’s picture

Patch from #17 (drupal_css-2014851-17.patch) works correctly against latest drupal 7.36.

David_Rothstein’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 7.x - thanks!

Fixed on commit (this list is in theory supposed to be kept up to date, as was done in the committed Drupal 8 patch):

diff --git a/modules/simpletest/tests/common.test b/modules/simpletest/tests/common.test
index 0f0347f..fcc9791 100644
--- a/modules/simpletest/tests/common.test
+++ b/modules/simpletest/tests/common.test
@@ -942,6 +942,7 @@ class CascadingStylesheetsUnitTest extends DrupalUnitTestCase {
    * - Proper URLs in imported files. (https://drupal.org/node/265719)
    * - Retain pseudo-selectors. (https://drupal.org/node/460448)
    * - Don't adjust data URIs. (https://drupal.org/node/2142441)
+   * - Files imported from external URLs. (https://drupal.org/node/2014851)
    */
   function testLoadCssBasic() {
     // Array of files to test living in 'simpletest/files/css_test_files/'.

We also should keep the files in css_test_files/css_subfolder in sync with the main ones, but I'll file a separate followup for that (affects Drupal 8 too).

  • David_Rothstein committed 00e7efc on 7.x
    Issue #2014851 by hlieberman, Wim Leers, bradjones1, markcarver: Drupal...
David_Rothstein’s picture

David_Rothstein’s picture

Version: 7.x-dev » 6.x-dev
Status: Fixed » Patch (to be ported)

And back to Drupal 6 for this issue (due to the backport tag), in case someone wants to work on it there.

mikeytown2’s picture

@markcarver
Heads up that AdvAgg ended up copying and patching most of core's logic. As a result I keep an eye on issues like this one so that the 2 are in sync for the most part :)
#2035817: Back port some code fixes for CSS optimizations

Perseids’s picture

Isn't there another solution? because patching the core every time there is an update is...
Update: never mind didn't notice this was fixed in 7.37

Status: Patch (to be ported) » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.