Views contextual filters with multiple values do not work with arguments containing spaces

Created on 21 February 2019, about 6 years ago
Updated 2 May 2023, about 2 years ago

Views contextual filters with multiple values do not work with arguments containing spaces.

This issue is summarized and is being addressed in D7 Views module: https://www.drupal.org/project/views/issues/1027458 .

Attached is a patch adapted from the above issue, it provides an extra option "Preserve spaces with multiple values" that fixes the issue when selected.

🐛 Bug report
Status

Needs work

Version

10.1

Component
Views 

Last updated about 3 hours ago

Created by

🇺🇸United States mukhsim

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇸United States AaronBauman Philadelphia

    There is a bigger problem here, which imo is relevant to this thread.

    Because of how this regex is written - [\w0-9-_\.], contextual filters do not work with arguments that contain any non-word characters.

    Just about any special character including common ASCII - !@#$%^&*()/\<>?"'~`= for example - will break the regex, and the view will silently fail.

    IMO, a proper fix would address this failure, and not be limited to this one very specific shortcoming about whitespace.

    Also needs tests to prevent further regression.

  • Status changed to Needs review about 2 years ago
  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.7
    last update about 2 years ago
    29,365 pass, 1 fail
  • 🇺🇸United States AaronBauman Philadelphia

    Here are tests that will demonstrate the failure with regard to special characters and spaces.
    While writing these tests, I discovered that existing tests already account for the undocumented space-delimiting behavior of the contextual argument handler, dating back to views 7.x, before it was included into core.

    So, bug or not, any change may break contrib space and will require a change record.

    Will need framework maintainer to weigh in as well.

  • Status changed to Needs work almost 2 years ago
  • I've spent the last few hours troubleshooting an issue that came down to exactly what AaronBauman mentions in #26. In my case, the field has an equals sign (=). I may be able to come up with a workaround for my case, but a fix for this would be greatly appreciated.

  • 🇨🇴Colombia mlargo2

    The patch #24 failed when using an argument without any spaces and contextual filter options "Allow multiple values" and "Preserve spaces with multiple values" enabled. So I re-rolled patch against #24 in Drupal 10.2.x.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    The last patch does not provide tests.

    Since patches are no longer tested, a merge request needs to be provided.

  • Pipeline finished with Failed
    17 days ago
    Total: 472s
    #478883
  • Pipeline finished with Failed
    9 days ago
    Total: 862s
    #486088
  • 🇨🇴Colombia mlargo2

    I updated the last patch so now it includes tests. It was applied on Drupal 10.x

  • 🇮🇹Italy apaderno Brescia, 🇮🇹
Production build 0.71.5 2024