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
For a views field, enabling Output this field as a link
and setting Link path
to something like:
my-custom-path?one=[field_value_one]&two=[field_value_two]
Can result in broken links due to handlers/views_handler_field.inc > views_handler_field::render_as_link()
not correctly determining the correct $path
when the query string has control characters, for example tabs.
This is because parse_url()
will replace control characters with _
, which isn't considered when $url['query']
is used later on.
Steps to reproduce
- Add a views field with custom link that includes a query string that uses values from other fields
- Other fields have control characters, for example tabs
- Observe link is broken
Proposed resolution
Correctly determine the path.
Current code:
$path = strtr($path, array('?' . $url['query'] => ''));
Possible solution:
$path = strtok($path, '?');
Remaining tasks
- Create patch and test solution
User interface changes
None.
API changes
None.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#2 | views-3322498-2.patch | 624 bytes | MustangGB |
|
Comments
Comment #2
MustangGB CreditAttribution: MustangGB commentedAnd a patch.