& 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 |
Jump to:
Description
& characters in the URI are converted to & , thereby redirecting to a wrong destination than originally intended.

#1
I fixed it by replacing:
<?php$url = check_plain($data[0]['value']);
?>
with
<?php$url = str_replace('&', '&', check_plain($data[0]['value']));
?>
Unless someone has another idea?
#2
Marked #352667: Changes charecters when submitted as a duplicate.
#3
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
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
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]);
}
}