Problem/Motivation
The JavaScript Views arguments setting (views.ajaxViews.views_dom_id:ID.views_args
) will get HTML escaped on line 62 of the views.module file, but when passed back to Drupal via AJAX and picked up on line 117 of ViewAjaxController.php the arguments are not decoded causing issues with any arguments that contain HTML entities. For example, a Views argument of "This & That" will be "This & That
" in the JavaScript settings object, but it will not get decoded when passed back to Drupal so the string "This & That
" will be used instead of the original string "This & That" on any AJAX request.
Steps to reproduce (there are probably easier ways to reproduce, but this is my set up):
- Create a entity reference field on a node of type foo like
field_type_bar_nodes
- Create a type bar node titled "This & That"
- Create two type foo nodes with the entity reference field referencing the "This & That" node
- Create a view page listing type foo nodes with AJAX enabled and a pager paging one node at a time
- Add a relationship with "Content referenced from field_type_bar_nodes"
- Configure a contextual filter using that relationship as a "Query parameter" filter
- Go to the view page at
/VIEW_URL?field_type_bar_nodes=This%20%26%20That
- Click the next button and notice how the pager does not work as it should by showing the second node
Proposed resolution
Decode the Views arguments on re-entry into Drupal.
Comments
Comment #2
Daniel KorteEdit: I wasn't sure if this required a test or not so I included a patch with and without a test.
Comment #3
Daniel KorteComment #5
LendudeThat is never a question, tests tests more tests :) Nice work on that.
How is this bug exposed in a functional set up? Is it ever? Some steps to reproduce exposing this bug would be great. That would give a better understanding of the severity and if we maybe need a functional javascript test for this too.
Comment #6
Daniel KorteComment #7
Daniel KorteHaha, yeah I figured. Thanks.
Steps added to the description! Please let me know if you have any trouble reproducing.
Comment #8
LendudeThanks for the steps, manually tested this and got the fail reproduced and fixed with the patch applied.
I have to say that seems like a pretty low percentage setup so I think just the unit test for this is fine.
Re-upping the patch to make it clear which patch I'm RTBC'ing
Comment #10
LendudeUnrelated fail in MediaLibraryTest
Comment #12
Daniel KorteUnrelated fail in MediaLibraryTest
Comment #15
larowlanCommitted 5ad7fe3 and pushed to 8.8.x. Thanks!
c/p as db905bd451 and pushed to 8.7.x
Unrelated fail in MediaLibraryTest