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):

  1. Create a entity reference field on a node of type foo like field_type_bar_nodes
  2. Create a type bar node titled "This & That"
  3. Create two type foo nodes with the entity reference field referencing the "This & That" node
  4. Create a view page listing type foo nodes with AJAX enabled and a pager paging one node at a time
  5. Add a relationship with "Content referenced from field_type_bar_nodes"
  6. Configure a contextual filter using that relationship as a "Query parameter" filter
  7. Go to the view page at /VIEW_URL?field_type_bar_nodes=This%20%26%20That
  8. 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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Daniel Korte created an issue. See original summary.

Daniel Korte’s picture

Edit: I wasn't sure if this required a test or not so I included a patch with and without a test.

Daniel Korte’s picture

Issue summary: View changes

The last submitted patch, 2: views-ajax-args-decoded-3048707-2-test-only.patch, failed testing. View results

Lendude’s picture

I wasn't sure if this required a test or not

That 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.

Daniel Korte’s picture

Issue summary: View changes
Daniel Korte’s picture

Haha, yeah I figured. Thanks.

Steps added to the description! Please let me know if you have any trouble reproducing.

Lendude’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
2.2 KB

Thanks 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

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 8: views-ajax-args-decoded-3048707-2.patch, failed testing. View results

Lendude’s picture

Status: Needs work » Reviewed & tested by the community

Unrelated fail in MediaLibraryTest

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 8: views-ajax-args-decoded-3048707-2.patch, failed testing. View results

Daniel Korte’s picture

Status: Needs work » Reviewed & tested by the community

Unrelated fail in MediaLibraryTest

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 8: views-ajax-args-decoded-3048707-2.patch, failed testing. View results

  • larowlan committed 5ad7fe3 on 8.8.x
    Issue #3048707 by Daniel Korte, Lendude: Views AJAX arguments are not...
larowlan’s picture

Status: Needs work » Fixed

Committed 5ad7fe3 and pushed to 8.8.x. Thanks!

c/p as db905bd451 and pushed to 8.7.x

Unrelated fail in MediaLibraryTest

  • larowlan committed db905bd on 8.7.x
    Issue #3048707 by Daniel Korte, Lendude: Views AJAX arguments are not...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.