Closed (fixed)
Project:
Drupal core
Version:
9.3.x-dev
Component:
block.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
22 Feb 2021 at 19:11 UTC
Updated:
20 Jun 2021 at 17:39 UTC
Jump to comment: Most recent, Most recent file



Comments
Comment #2
cilefen commentedComment #3
larowlanComment #5
gauravvvv commentedWorking fine on 9.1 and 9.2
Attached a screenshot for reference.
Comment #6
shriaasWorking fine on 8.9.x-dev attaching screenshot for same.
Comment #7
pameeela commentedThis was very easy to reproduce using the steps provided (i.e. a views block, not a custom block) but I have updated the summary to be a bit clearer.
Comment #8
gauravvvv commentedHello @pameeela, I am using view block, and still not reproducible to me on a fresh install. Adding screenshot for reference.
Comment #9
pameeela commented@Gauravmahlawat your screenshot shows that you have set the block title, not the display name. Please see the screenshot referenced in the issue summary.
Comment #10
pameeela commentedUpdated STR to clarify.
Comment #11
gauravvvv commented@pameeela, thank you for clarifying. This issue reproducible now.
Comment #12
abhijith s commentedBefore patch:

After patch:

Please review this.
Comment #13
abhijith s commentedComment #14
shriaasPatch applied successfully on 8.9.x-dev. Issue is resolved after applying the patch, attaching screenshots for same:
Comment #15
gauravvvv commented#12 looks good. Moving to RTBC +1
Comment #16
larowlanStill needs tests - thanks
Comment #17
mohit_aghera commentedAdding new test cases with sample view.
Fixed existing failures.
Comment #18
mohit_aghera commentedFixing phpcs issues in the patch.
Comment #19
roman-yrv commentedI've just tested it.

Unfortunately, it isn't fixed now.
Comment #20
roman-yrv commentedSorry, I've made a mistake in my previous comment.

I've tested it again with this patch (https://www.drupal.org/files/issues/2021-03-03/3199730-18.patch), it works!
Comment #21
ranjith_kumar_k_u commentedThe last patch works fine


Before patch
After patch
RTBC.
Comment #22
gauravvvv commentedDon't forget to change the status when moving to RTBC.
Comment #23
gauravvvv commentedComment #24
larowlanThanks everyone, can we get a test-only patch here that fails, to demonstrate the new test-coverage resolves the issue.
Any reason we're putting this in one of the Wizard tests and not in a general Views UI test?
Comment #25
mohit_aghera commentedThanks, @larowlan. I'll add the test-only patch.
My main intention to keep in Wizard was that, while placing the block it follows the block placement flow. i.e. visit the admin/structure/block page etc. So I thought of to keep in Wizard/BasicTest.php and views module.
Later I realized that we can test it directly by visiting the page
admin/structure/block/add/views_block%3Aarticles_and_pages-block_1/Should I move it along with views_ui module's test cases?
Comment #26
larowlan\Drupal\Tests\views_ui\Functional\XssTestwould be a good spot I guess, because it already hastestNoDoubleEscapingComment #27
mohit_aghera commentedRefactored test cases and moved to relevant place.
Comment #29
mherchelThis is is not related to Olivero.
Comment #30
mohit_aghera commented@mherchel I think it got updated by mistake. Sorry for the confusion.
Moving it to needs review as failures is related to test-only patch.
Comment #31
ilgnerfagundes commentedI did the test locally and the title is getting correct, and the test that failed that was previously requested seems to be working correctly as well.
Comment #34
larowlanCommitted fd9f708 and pushed to 9.2.x. Thanks!
Backported to 9.1.x
For future reference folks, one set of before/after screenshots is enough.
If you come to an issue and find someone else has added them, move on.
Comment #35
larowlanComment #38
larowlanWas discussing this with @alexpott who pointed out we should be limiting the allowed tags via
So I've reverted this.
Can we add that function in folks.
Comment #40
larowlanComment #41
alexpottThis has been plain text since D7... see the following code from D7:
so changing this to support html needs a big security think...
My original thought was to change to use a more restrictive tag list. This has the advantage or supporting some tags but being way more restrictive than the admin list that's the default for #markup.
The other option would be to do
This would have the advantage of not changing the behaviour. However, I think restricting the taglist is probably best because then admin labels that have been translated can use tags like bdo which are specifically for translations.
Comment #42
mohit_aghera commentedHi @larowlan @alexpott
I tried to add #allowed_tags on the label field, somehow it is not working as expected.
Can it be because it is specifically for render elements?
To confirm this, I've added test-only patch.
For the implementation, I took different approach and added code inside
ViewsBlockderivative plugins.We can filter tags there and then render markup in
BlockPluginTraitclass.I've updated patch accordingly.
Can you please confirm if this is the right approach.
Comment #43
mohit_aghera commentedUploading patch by resolving phpcs issues.
Comment #44
alexpott@mohit_aghera
'#allowed_tags' => Xss::getHtmlTagList(),works as I would expect it.One thing that is apparent is that we need to match what we do in
\Drupal\Core\Block\BlockPluginTrait::buildConfigurationForm()in\Drupal\block\BlockListBuilder::buildBlocksForm()This needs the same change.
Comment #45
alexpottHowever a problem with using Xss::getHtmlTagList() is that it doesn't allow bdo or any of the other translation related tags and it does allow ul and li which have no business in the form or the listing page. So perhaps the PlainTextOutput::renderFromHtml() is the best solution for now. We should consider opening an issue to add a list of tags for titles that only includes inline html tags.
If we're going to use PlainTextOutput::renderFromHtml() then we can leave this as #plain_text.
Comment #46
alexpottThis issue is a sort of duplicate of #2568045: Make it impossible to double escape with #plain_text - which is about the wider problem. Also this issue gives me an idea about a good fix for that.
Comment #47
alexpott#2568045: Make it impossible to double escape with #plain_text now has an alternate fix in the heart of the render system that will help all cases of #plain_text => MarkupInterface object - it includes some of the test developed here so if we decide to go forward with that we should transfer credit for people who developed the test to that issue and mark this one as a duplicate.
Comment #48
mohit_aghera commented@alexpott
I think that makes sense.
We can close this one and continue work in #2568045
I think that patch seems not getting applied on 8.9.x branch. I can take care of that if we plan to close this one.
Comment #50
kumar ashutosh commented