Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
theme system
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
13 Jun 2015 at 17:40 UTC
Updated:
29 Jun 2015 at 04:24 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
pwolanin commentedComment #2
pwolanin commentedComment #4
star-szrCool idea!
Comment #5
pwolanin commentedSomething wrong with my conversion to implode(), but that wasn't really needed anyhow.
Comment #6
akalata commentedThis patch documents an acceptable use of SafeMarkup::set, replacing 4 SafeMarkup calls with htmlspecialchars() and only marking the final result as safe.
I did notice a comment in Attribute.php that needs to be updated:
Comment #7
pwolanin commentedThanks, here's a fix for that comment.
Comment #8
yesct commentedread the whole patch,
and applied it and looked at it in context.
grepped for checkPlain in core/lib/Drupal/Core/Template
and after the patch, the only occurrence is TwigExtension
so, got all them out of the Attribute helpers. ok.
most of the replacements are of the pattern:
and I was wondering how the args to htmlspecialchars was choosen, why ENT_QUOTES and UTF-8?
looking at checkPlain, can see that that is what checkplain was doing anyway, so that makes sense.
got most of the (now) unused use's out... except for the one in AttributeArray.
I think if a patch with that out comes back ok, this is rtbc.
Comment #9
pwolanin commentedComment #10
yesct commentedas long as it comes back green, rtbc.
Comment #11
star-szrLooks good. Also makes me think we might want a check plain that doesn't mark as safe, similar to what was being discussed in #2399261: Remove SafeMarkup::set and Recheck and Mark Safe the Output of Unicode::truncate() in DbLog. Not sure though.
Comment #12
pwolanin commented@Cottser - maybe, but it's also not hard to use htmlspecialchars()
Partly why we didn't use it directly in Drupal 7 and before and had check_plain() as a wrapper is that it did not include UTF-8 validation.
Comment #13
xjmThis is another great cleanup to reduce SafeMarkup overuse. Thanks @pwolanin.
To clarify #12, checkPlain() is exactly
htmlspecialchars($text, ENT_QUOTES, 'UTF-8')plus adding the string to the safe strings list. I checked with @pwolanin and it looks like the UTF-8 validation was added tohtmlspecialchars()following PHP 5.2.5; @pwolanin linked: https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/chec...Can we get a followup to either document on AttributeValueBase::render() (note there isn't an interface...) that child implementations are responsible for sanitizing values?
This issue is a required part of a critical task and is allowed per https://www.drupal.org/core/beta-changes. Committed and pushed to 8.0.x.
Comment #15
xjm