Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Views attachment titles are double escaped.
The title as entered
The title displayed in the admin section of the view.
The title displayed in the preview section.
Note that this issue was committed and reverted.
Steps to reproduce
- Create an attachment display for a view
- Create a title with special characters
- View the title in the preview section of the view
Proposed resolution
TBA
Remaining tasks
Test
Patch
Review
Commit
User interface changes
Yes - Add update to date screeenshots here
API changes
N/A
Data model changes
N/A
Release notes snippet
N/A
Comment | File | Size | Author |
---|---|---|---|
#55 | 2598502-55.patch | 1.03 KB | jmdeleon |
#51 | Screenshot_2021-11-09 Atest2 (Content) dev0-web(3).png | 5.01 KB | quietone |
#51 | Screenshot_2021-11-09 Atest2 (Content) dev0-web(1).png | 2.41 KB | quietone |
#51 | Screenshot_2021-11-09 Atest2 (Content) dev0-web(2).png | 4.06 KB | quietone |
#47 | string-2598502-46.patch | 1.03 KB | sam-elayyoub |
Comments
Comment #2
alexpottComment #3
alexpottThe test only patch passed because it was checking for a double escaped
&
- it should have been checking for a double escaped<
.Added proper testing of this in
DisplayAttachmentTest
Comment #5
dawehnerDo you mind having a more explicit test for that?
Comment #6
dawehnerTagging for Medium
Comment #7
xjmThe core committers and Views maintainers (alexpott, xjm, effulgentsia, tim.plunkett, and dawehner) agreed that this is not a major issue (despite @alexpott originally filing it as such).
Comment #8
dawehnerNeeds work due to #5
Comment #9
alexpottImproving the test.
Comment #10
dawehnerThank you alex!
Comment #11
catchCommitted/pushed to 8.1.x and cherry-picked to 8.0.x. Thanks!
Comment #14
edurenye CreditAttribution: edurenye at MD Systems GmbH commentedThis change breaks everything, I have errors like this in some modules, and get's fixed reverting this line.
Comment #16
catchOK reverted from 8.0.x for now.
Leaving this in 8.1.x for a bit longer - can you post a longer backtrace or example code that's triggering this?
Comment #17
edurenye CreditAttribution: edurenye at MD Systems GmbH commentedThe full backtrace:
I was opening a form that changes the title and adds breadcrumbs.
It was in TMGMT but also it happened to a coworker that was working in this Core issue #2640994: Label token replacement for views entity reference arguments not working
Comment #18
tduong CreditAttribution: tduong at MD Systems GmbH commentedDebugged and if you do a string cast on
'_title' => (string) $this->view->getTitle(),
in \Drupal\views\Plugin\views\display\PathPluginBase::getRoute() (line 137) it fixes the bug.Comment #20
catchOK that looks like we're missing some core test coverage then. Reverted from 8.1.x as well.
Comment #21
BerdirYes, we do, no idea why none of our tests are failing.
Also, it's wrong that this string is being translated in the first place. It is user provided data and shouldn't be run through t(). That's an existing problem but it might be the proper way to solve this. TitleResolver::getTitle() needs a way to not run _title through t(), based on some flag I guess.
Or views needs to use a _title_callback instead.
Comment #22
dawehner@edurenye @berdir
Do you mind providing the view which caused the issue?
Well, in general we cannot do that for everything as the computational overhead would be too crazy. We though add some static title in there:
Comment #23
BerdirTo reproduce, just apply the patch, clear cache and go to d8/admin/content/comment. Boom. Any page that has a view in the path parents causes this.
Comment #24
dawehnerwow, I would have expected we have test coverage for that page.
Comment #25
swentel CreditAttribution: swentel commentedI've hit this as well on admin/content - but not sure how I got it like that. I have a dump where it fails, but after simply clearing cache or saving the view without changing anything it's fine. Will try this patch on to see if it's ok without clearing the cache.
Comment #30
BerdirDo we need explicit (web) test coverage for that bug?
Comment #31
dawehnerYeah I guess @berdir is totally right here.
Comment #38
brayfe CreditAttribution: brayfe as a volunteer commentedRunning into this issue with a specific Media Library view in 8.6.4 and hoping this patch will fix it. Since the patch didn't apply cleanly for 8.6.4, I re-rolled it.
Comment #41
sam-elayyoub CreditAttribution: sam-elayyoub as a volunteer and commentedthis is a patch I used to make it work but it works :-) simply convert if it's not string to string.
Comment #42
sam-elayyoub CreditAttribution: sam-elayyoub as a volunteer and commentedSorry here's the patch using composer or direct core
Comment #43
sam-elayyoub CreditAttribution: sam-elayyoub as a volunteer and commentedThe core was there my bad in the path here's the new one
Comment #44
sam-elayyoub CreditAttribution: sam-elayyoub as a volunteer and commentedComment #45
sam-elayyoub CreditAttribution: sam-elayyoub as a volunteer and commentedpath fix
Comment #46
sam-elayyoub CreditAttribution: sam-elayyoub as a volunteer and commentedComment #47
sam-elayyoub CreditAttribution: sam-elayyoub as a volunteer and commentedworks on composer the last patch but here's the one that works on jenkins
Comment #51
quietone CreditAttribution: quietone as a volunteer commentedThanks to danflanagan8 for teaching what a Views 'attachment' is.
I tested this on 9.3.x, standard install, and the problem persists. One thing that was unexpected is the title is not displayed on the view, only on the preview of the attachment.
Not sure if this should be in the view_ui component or not.
Comment #52
LendudeWe did a pretty generic fix here, #2872322: Views preview title is double escaped, so a little surprised that attachments are still broken
Comment #55
jmdeleon CreditAttribution: jmdeleon at OpenPlus commentedRe-rolling patch in #47 to use PHP __toString() method to get a cleaner string representation versus an object serialization.