Updated: Comment #15

Problem/Motivation:

When creating an identical copy of garland and minnelli for customization I found that I could not use the color module support to change colors. The images were generated but the paths in the CSS were wrong. I added some error_log debugging and discovered that the regular expression that is being used to determine image path for replacement (coalescing ..) for will not match a 2-character subtheme name. The paths are then not replaced, leading to invalid image references in the css.

Proposed resolution:

Patch at Comment #15 . This patch changes regular expression to take 2-character subtheme name.

Remaining tasks:

Testing patch is required if the regular expression is correct and also issue at https://drupal.org/node/466268 conflicts the code with the patch #15

User interface changes

n/a

API changes

n/a

n/a

Original report by @ahamid

When creating an identical copy of garland and minnelli for customization I found that I could not use the color module support to change colors. The images were generated but the paths in the CSS were wrong. I added some error_log debugging and discovered that the regular expression that is being used to determine image path for replacement (coalescing ..) for will not match a 2-character subtheme name. The paths are then not replaced, leading to invalid image references in the css.

The PCRE regex in my color.module is: `(^|/)(?!../)([^/]+)/../`

Here is some debug illustrating the problem.

First, Minnelli, which works:

[12:44:22.760] {http--8686-10} base_path(): /
[12:44:22.760] {http--8686-10} before: ../images/bg-navigation.png
[12:44:22.760] {http--8686-10} after: bg-navigation.png
[12:44:22.760] {http--8686-10} before: /themes/garland/minnelli/../images/bg-navigation.png
[12:44:22.761] {http--8686-10} Before after regex: /themes/garland/images/bg-navigation.png
[12:44:22.761] {http--8686-10} replacing '/themes/garland/images/bg-navigation.png' with 'bg-navigation.png in css

Now, my custom subtheme ('ww'):

[12:42:06.858] {http--8686-1} base_path(): /
[12:42:06.858] {http--8686-1} before: ../images/bg-navigation.png
[12:42:06.858] {http--8686-1} after: bg-navigation.png
[12:42:06.859] {http--8686-1} before: /sites/all/themes/custom-garland/ww/../images/bg-navigation.png
[12:42:06.859] {http--8686-1} Before after regex: /sites/all/themes/../images/bg-navigation.png
[12:42:06.859] {http--8686-1} replacing '/sites/all/themes/../images/bg-navigation.png' with 'bg-navigation.png in css

Notice that the 'before' path after the regex is wrong.

I verified this behavior via an online PCRE regex checker:

http://www.quanetic.com/regex.php

The Minnelli path yields:

Here's where the pattern was found:

/themes/garland[!MATCH!]images/bg-navigation.png

Parenthesized substring matches:

* substring 1: /
* substring 2: minnelli

My custom subtheme yields:

Here's where the pattern was found:

/sites/all/themes[!MATCH!]../images/bg-navigation.png

Parenthesized substring matches:

* substring 1: /
* substring 2: custom-garland

It is replacing the parent theme, not the subtheme. Interestingly, if the subtheme name is changed to 1 character, or more than 2 characters, the matching works.

I have not yet tried to fix the regular expression but may followup with a fix if I can.

Issue fork drupal-276384

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

ahamid’s picture

Status: Active » Needs review

Ok, the fix for the regex is to *escape* the dots in ../ :

`(^|/)(?!\.\./)([^/]+)/\.\./`

Since "dot" means "Match any single character" I suspect that this was leading the expression to be broken for JUST themes that were two characters long. Lucky me to stumble upon that ;)

This fix must be applied in modules/color.module as well as includes/common.inc _drupal_build_css_path.

Let me know if you need an official patch/diff for this.

Thalassa’s picture

Just wanted to say thank you for posting this. Was banging my head for 24 hrs with my two character subtheme name.

TheComrade’s picture

Version: 6.2 » 6.13

This wacky module also fails in the same way if there are two character paths involved. e.g. if drupal is installed at http://site.com/util/cs/drupal.

torotil’s picture

I was just hitting this very same issue in drupal 7.2. Why is the fix still not applied?

torotil’s picture

Version: 6.13 » 7.x-dev
FileSize
612 bytes
iSampo’s picture

FileSize
614 bytes

Patch for escaping all of the dots.

torotil’s picture

Status: Needs review » Reviewed & tested by the community

RTBC.

jpstrat’s picture

Version: 7.x-dev » 7.15
Status: Reviewed & tested by the community » Needs work
FileSize
39.62 KB

I tested this patch with Drupal 7.15 (renamed to drupal_views) and found the problem still exists.

I started by examing the patch itself vs drupal-7.15/modules/color where I found color.module. I opened the module and found that the patch in item 6 above has been included in the Drupal-7.15 distribrution.

I then copied the Bartik theme from /drupal-views/themes to /drupal-views/sites/all/themes and renamed the directory xy from Bartik. Inside the Bartik directory I renamed the Bartik.info file xy.info.

I then went to the Appearance tab to look for my new xy theme. I didn't find it, but I did find a second copy of Bartik. I clicked the "enable and set default" button for the new Bartik then went to the home page. It looked just like a normal Bartik home page. I clicked Appearance and the settings for my new theme. I then manipulation the color wheel to show very different colors. The preview showed that the colors were changed. I clicked "Save Configuration" and went to the home page. The colors remained the basic Bartik blue.

I re-enabled the stock Bartik theme. I then changed my xy directory to xyz and my xy.info to xyz.info. I then enabled the xyz theme. I found the changes I had earlier saved were implemented without me making any further changes.

Additionally, I received the following errors with the xy naming:
"Notice: Undefined variable:hide_site_name in include() (line 99 of C:\sites\Uniserver\www\drupal-views\sites\all\themes\xy\templates\page.tpl.php)."
"Notice: Undefined variable:hide_site_name in include() (line 109 of C:\sites\Uniserver\www\drupal-views\sites\all\themes\xy\templates\page.tpl.php)."

iSampo’s picture

Status: Needs work » Reviewed & tested by the community

@jpstrat:

- Just checked out 7.15 and the patch has not been applied there.
- Your xy theme on the Appearance page was named Bartik because you didn't change the theme 'name' value on the .info file.
- Your notices came from your copy of template.php. Rename all bartik_ functions (such as bartik_process_html, bartik_process_page, etc.) to YOURTHEMENAME_process_html, etc. That way you'll get rid of the notices.

Tested on these steps (+ applied the patch + cleared Drupal cache), and it works.

webchick’s picture

Version: 7.15 » 8.x-dev
Status: Reviewed & tested by the community » Needs work

Awesome, thanks for the fix, folks!

Two things:

1) We actually need to apply this to 8.x first (http://drupal.org/node/767608), so would someone mind re-rolling for that?
2) As long as you have your head in the regex and understand it, any way to add a one or two-liner comment above it to explain what the heck it's doing for the next person? :)

We normally require tests for bug fixes, but since color module doesn't currently have any tests, I don't think that should hold this patch up, since we're unlikely to touch this regex again once we've fixed it. I've created #1805118: Add tests for Color module as a follow-up, though.

steinmb’s picture

Need an issue summary

markhalliwell’s picture

Issue tags: +Novice, +Needs reroll

#6 needs a reroll against D8. Let's commit to D8 first. Then verify patch in #6 is still viable for D7, if not reroll again.

dlu’s picture

Status: Needs work » Needs review
Issue tags: -Needs issue summary update, -Novice, -Needs reroll

#6: color_regex_fix-276384.patch queued for re-testing.

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

The last submitted patch, color_regex_fix-276384.patch, failed testing.

dlu’s picture

Assigned: Unassigned » dlu
Status: Needs work » Needs review
FileSize
634 bytes

Rerolled to D8. Patch in #6 is being retested, so that may do the job of a backport to D7.

dlu’s picture

This is a reroll of the patch in #15 to D7.

Once #15 is committed to D8, this could be uploaded as a patch and the version changed to D7.

markhalliwell’s picture

Assigned: dlu » Unassigned
Status: Needs review » Needs work
Issue tags: -Novice, -Needs reroll +Needs tests

Great patch @dlu! Thanks! It passes with flying colors, heh :)

I'm marking this as NW and adding tag though since we really should be testing that this regex works as expected (per #10 and core gates).

markhalliwell’s picture

Issue tags: +Needs backport to D7

tagging for #16

dlu’s picture

Issue tags: -Needs backport to D7

This patch and https://drupal.org/node/466268 affect the same line of code. https://drupal.org/node/466268 includes the changes in this patch.

aparnakondala1’s picture

Issue summary: View changes

Updated issue summary.

aparnakondala1’s picture

Issue summary: View changes

Updated issue summary.

aparnakondala1’s picture

Issue summary: View changes

Updated issue summary.

aparnakondala1’s picture

Issue summary: View changes

Updated issue summary.

aparnakondala1’s picture

Issue summary: View changes

Updated issue summary.

aparnakondala1’s picture

Issue summary: View changes

Updated issue summary.

aparnakondala1’s picture

Issue summary: View changes

Updated issue summary.

sanguis’s picture

Assigned: Unassigned » sanguis
Issue summary: View changes

starting on the tests

mgifford’s picture

Assigned: sanguis » Unassigned

This still a concern in D8? Unassigned issue too.

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.

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.

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.

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.

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.

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.

quietone’s picture

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

Still an issue, The regex has not changed in 9.2.x

Spokje made their first commit to this issue’s fork.

Spokje’s picture

Assigned: Unassigned » Spokje
Spokje’s picture

Issue Summary was updated after the tag was given (#11) in #19.1 up to #19.6 and is pretty clear to me.

Removing tag

Spokje’s picture

Assigned: Spokje » Unassigned

Still needs tests as per #17.

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.

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.

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.

quietone’s picture

Project: Drupal core » Color backport
Version: 9.5.x-dev » 2.x-dev
Component: color.module » Code

Color has been removed from core, #3270899: Remove Color module from core.