Hi.
I just discovered a little issue trying to use the module ajaxblocks.
Scenario:
Block loaded by ajaxblocks is brought by this url: ajaxblocks?blocks=[module-BLOCK]&path=[path_of_url_where_the_block_is_invocked]&nocache=[1|0]&_=XXX
The problem is when the url has an encoded ampersand (&) in the original path the generated url to call the ajax block does not encode again the umpersand (&) resulting in a url with non-encoded ampersand and the server understands that as a new variable in the query.
original url: /foo/BAR%26NIGHT
generated path inside the url to call ajaxblock: path=foo/BAR&NIGHT
PROBLEM:
The problem is that in my project I need to read the complete PATH and I think with a contribution it will solve a future problem for other people.
SOLUTION:
I changed this:
if (count($block_ids) > 0) {
drupal_add_js(array('ajaxblocks' => 'blocks=' . implode('/', $block_ids) . '&path=' . $_GET['q'] . $get_params), 'setting');
if ($min_delay > 0) {
drupal_add_js(array('ajaxblocks_delay' => $min_delay), 'setting');
}
}
if (count($block_ids_late) > 0) {
drupal_add_js(array('ajaxblocks_late' => 'blocks=' . implode('/', $block_ids_late) . '&path=' . $_GET['q'] . $get_params), 'setting');
if ($min_delay_late > 0) {
drupal_add_js(array('ajaxblocks_delay_late' => $min_delay_late), 'setting');
}
}
Into this:
if (count($block_ids) > 0) {
drupal_add_js(array('ajaxblocks' => 'blocks=' . implode('/', $block_ids) . '&path=' . urlencode($_GET['q']) . $get_params), 'setting');
if ($min_delay > 0) {
drupal_add_js(array('ajaxblocks_delay' => $min_delay), 'setting');
}
}
if (count($block_ids_late) > 0) {
drupal_add_js(array('ajaxblocks_late' => 'blocks=' . implode('/', $block_ids_late) . '&path=' . urlencode($_GET['q']) . $get_params), 'setting');
if ($min_delay_late > 0) {
drupal_add_js(array('ajaxblocks_delay_late' => $min_delay_late), 'setting');
}
}
I already tested the code and it works. It will also be useful for other people that needs to work with the original path.
Cheers.
Comment | File | Size | Author |
---|---|---|---|
#2 | ampersand-in-path-2699839.patch | 1.05 KB | malcaino |
ampersand-in-path-xxx-yyy.patch | 1.05 KB | malcaino |
Comments
Comment #2
malcaino CreditAttribution: malcaino as a volunteer and commentedWell. This is the patch file to apply the fix to this:
Can we commit this as soon as possible?
Thanks!
Comment #3
lolandese CreditAttribution: lolandese at HCL Technologies Limited commented