Hyphens and forward slashes (-/) break Views contextual filters

Created on 2 January 2010, almost 15 years ago
Updated 20 September 2024, about 2 months ago

Problem/Motivation

Views contextual filters break when values contain forward slashes or when they contain hyphens and the "Transform spaces to dashes in URL" option is enabled. If a view is configured to display a summary if the filter value is not in the URL in one of these two cases, Views will print links that lead to broken pages. See #29 for a detailed description of the symptoms.

Proposed resolution

The solution may be to specially encode hyphens and forward slashes. (There are some workarounds detailed in #16 that may help folks who need a solution now.)

Remaining tasks

  • Code the changes
  • Write regression tests

User interface changes

Probably none.

API changes

None, per se. Encoding and decoding rules for contextual filters may change slightly.

Original report by @TravisCarden

A View with an argument set to display a summary if the argument is not present will create non-functioning links (or, more precisely, links to paths with arguments that don't work) if the terms (I've only tested with taxonomy arguments) contain any pound signs, plus signs, dashes, or backslashes (#+-/). The following special characters work just fine: !"$%&'()*,.:;<=>?@[\]^_`{|}~. I didn't test anything crazier than that. I realize this may be somewhat expected behavior, but I'm going to argue it's a bug because the broken links themselves are being generated by Views.

πŸ› Bug report
Status

Needs work

Version

11.0 πŸ”₯

Component
ViewsΒ  β†’

Last updated about 21 hours ago

Created by

πŸ‡ΊπŸ‡ΈUnited States traviscarden

Live updates comments and jobs are added and updated live.
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.

  • πŸ‡³πŸ‡¬Nigeria chike Nigeria

    I applied #69 on Drupal 9 and I still have the scenario described at #32 πŸ› Hyphens and forward slashes (-/) break Views contextual filters Needs work being that for terms without dashes in the names like 'two words' the page would load but for terms with a dash in the name like 'two-words' it would be page not found.

    'two words' url = 'two-words'
    'two-words' url = 'two-words'

    The former loads the page the latter shows page not found.

    I got 'Transform dashes in URL to spaces in term name filter values' turned on.

    Before I applied the patch I think I had exact same experience at #32 like turning 'Transform dashes in URL to spaces in term name filter values' on and off will switch back and forth to working for the 2 scenarios like if turned on it works when a dash is in the name and when turned off it works when no dash in the name and stops working for when there is a dash in the name. I cannot remember exactly if this was so but I remembered that when I first noticed some pages showing page not found I fiddled and turned on 'Transform dashes in URL to spaces in term name filter values' and the issue went away not until some other day I clicked a page and it wasn't working then I turned off 'Transform dashes in URL to spaces in term name filter values' and it started working for the page. I didn't think about terms with a dash in the name or not as at then but I kept getting confused as I kept turning 'Transform dashes in URL to spaces in term name filter values' on and off and each time it would work for the page I was on and tomorrow I check some other page and it won't be working.

    Now with patch #69 it only works for terms with no dashes in the names i.e. 'two words' and for 'two-words' it won't work either 'Transform dashes in URL to spaces in term name filter values' is turned on or off.

  • πŸ‡³πŸ‡¬Nigeria chike Nigeria

    I tried this patch ✨ Let the 'Transform dashes in URL to spaces in term name filter values' find terms that should contain the dash Needs work instead and it worked better.
    Both 'two words' and 'two-words' term names work.

  • πŸ‡³πŸ‡¬Nigeria chike Nigeria

    Well I thought 'it worked better' but it doesn't so I am back here and will go back to patch #69 πŸ› Hyphens and forward slashes (-/) break Views contextual filters Needs work once I resume work tomorrow.

  • πŸ‡¬πŸ‡§United Kingdom joehuggans Harrogate, UK

    #69 working with Drupal 10.2.3

    Our issue was specifically with forward slashes in an argument.

  • πŸ‡¦πŸ‡ΊAustralia acbramley

    Needs a reroll onto an MR.

  • πŸ‡¦πŸ‡ΊAustralia acbramley

    Rolled into MR, still NW based on #78

  • Pipeline finished with Failed
    about 2 months ago
    Total: 240s
    #287770
  • Pipeline finished with Failed
    about 2 months ago
    Total: 603s
    #287773
Production build 0.71.5 2024