& characters

yaronw - June 27, 2008 - 17:48
Project:CCK Redirection
Version:6.x-1.2
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:needs review
Description

& characters in the URI are converted to & , thereby redirecting to a wrong destination than originally intended.

#1

DamienMcKenna - December 23, 2008 - 00:17
Status:active» needs review

I fixed it by replacing:

<?php
        $url
= check_plain($data[0]['value']);
?>

with

<?php
        $url
= str_replace('&amp;', '&', check_plain($data[0]['value']));
?>

Unless someone has another idea?

#2

choster - January 4, 2009 - 01:30

#3

btopro - January 13, 2009 - 18:30

I change the _cck_redirection_divert function to account for node prepopulate urls. If you don't do this they won't complete correctly. It still does normal redirects correctly too.

function _cck_redirection_divert($element) {
//print $element['#item']['value'];
$url = $element['#item']['value'];
$urls = explode("&",$url,2);
drupal_goto($urls[0],$urls[1]);
}

This works in the 6.x version at least

#4

greenbeans - February 1, 2009 - 03:13

I'm seeing a similar problem, but rather than HTML-encoding query strings, they're being URL-encoded, so that (for instance) a CiviCRM URL such as

http://example.com/civicrm/contribute/transact?reset=1&id=4

becomes:

http://example.com/civicrm/contribute/transact%3Freset%3D1%2526id%3D4

... which unsurprisingly results in an "access denied" error.

Is there any workaround for this?

Thanks.

#5

btopro - August 27, 2009 - 14:24
Version:5.x-1.0» 6.x-1.2

This problem still exists. My fix above works. This function needs to be changed to

function _cck_redirection_divert($element) {
if (!empty($element['#item']['value'])) {
$url = $element['#item']['value'];
$urls = explode("&",$url,2);
drupal_goto($urls[0],$urls[1]);
}
}

 
 

Drupal is a registered trademark of Dries Buytaert.