Problem/Motivation
This was initially reported in #3525103: Allow Xss::filter() to restrict allowed attributes.
Having the strict argument set to true is a good practice, otherwise it can lead to unexpected behavior (see #3295295: [META] Always call in_array() in strict mode).
Steps to reproduce
Proposed resolution
Add the strict argument.
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
Issue fork drupal-3608303
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:
- 3608303-inarray-calls-in
changes, plain diff MR !16213
Comments
Comment #3
prudloff commentedComment #4
ghost of drupal pastthis is superfluous because unlike the issue i reported in you do know the type of the needle and the haystack both:
$attribute_name = strtolower($match[1]);
$skip = (
in_array($attribute_name, ['style', 'srcdoc']
the needle is a string since it comes from strtolower and the haystack is a list of fixed non empty strings so there's no need to strict match them. In the other issue I raised a red flag because heaven knows what's in allowed_attributes
of course it doesn't hurt but it's not necessary either
Comment #5
smustgrave commented@prudloff thoughts for arguing for?
Comment #6
prudloff commentedI don't have a strong opinion about this.
ghost of drupal past is probably right and I might have been a bit too quick to create this issue.
That said, I think we should have a CI rule that forces using strict mode everywhere (this is proposed in #3295295: [META] Always call in_array() in strict mode).
So we could either:
Comment #7
smustgrave commentedMR is already up lets see what committers say
Comment #11
catchYeah while this might not fix anything it will be one less thing to review when we introduce the rule and has no downside.
Committed/pushed to main and 11.x, thanks!