Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
color.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
1 Oct 2019 at 14:39 UTC
Updated:
28 Mar 2020 at 16:24 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
avpadernoComment #3
taran2lComment #4
avpadernoThe actual code used from the function is the following one.
Unconditionally removing the leading # is not necessary as, at least in one case, it is already removed. I would rather change the code as follows.
The Color module doesn't seem to validate the value used for
$hex, which could also contain'99#ff'. In this case, filtering out any character that isn't acceptable as hexadecimal digit would be better.Comment #5
avpadernoComment #6
taran2l@kiamlaluno, I disagree with just removing everything, because Color module does input validation allowing either #XXX or #YYYYYY only:
then
and finally
Comment #7
avpadernoIf it's sure that
$hexwill always contain a string matching'/^#([a-f0-9]{3}){1,2}$/iD', then the function code should be the following one.Comment #8
mcdruid commentedThis was addressed in D8 in #3086374: Make Drupal 8 & 9 compatible with PHP 7.4
As far as I can see there's no discussion of this code specifically in the issue, but between #29 and #30 the fix went from:
...to:
Leaving us with the code in D8 now:
I don't find this code the most intuitive to read, but it makes sense given what @Taran2L mentioned in #6:
We should be consistent with D8 wherever possible, so let's backport the same change.
Comment #9
mcdruid commentedAs noted in other issues, I'm not sure this method is perfect, but if we compare the exceptions from the no-op patch in #3081386-49: [META] Fully support PHP 7.4 in Drupal 7 with those from the PHP 7.4 test for #8:
...that seems to confirm that the patch fixes the issue on line 740 of color.module:
https://git.drupalcode.org/project/drupal/-/blob/7.x/modules/color/color...
I'm not certain why the number of exceptions from element_children() also goes up, but we're addressing that in #3084935: element_children() and DrupalRequestSanitizer::stripDangerousValues() should not use integer keys as array and that Notice should go away once that issue's done.
As the change here is exactly the same as the one committed to D8, I'm confident enough to mark this RTBC and ready for final review.
Comment #10
fabianx commentedReady to be merged - let's get this in. Thanks all!
Comment #12
mcdruid commentedAnother one done; thanks everyone!