Plugin redirect issue - htmlentities added to url

424 views
Skip to first unread message

Alan Sparkes

unread,
Jun 30, 2012, 9:09:22 AM6/30/12
to joomla-de...@googlegroups.com
I have a plugin which intercepts the request to edit content and redirects to my component controller.

Environemnt
Mamp
php 5.3 / Joomla 2.5.4

It looks like this:

$mainframe = JFactory::getApplication();
//do some checks and then 
 
 $link = 'index.php?option=com_mycomp&sectionid=' . $sectionid . '&task=edit&cid[]=' . $id . '&version=' . $v . '';
        
$mainframe->redirect($link, $msg);

The weird thing is that the redirect url is rendering the '&' as ampersands/entites like '&'

So i get a redirected url from the $mainframe like this:
com_mycomp&sectionid=&task=edit&cid[]=71&version=1
 
So instead of routing to my components edit function it hits a different function altogether! 
If i manually remove the "&" from the url then it hits my edit function.

AM stumped to see how the "&" are getting into the urls.......

Anyone come across this?

Can post more code :)

Imanol Pérez Iriarte

unread,
Jun 30, 2012, 9:50:29 AM6/30/12
to joomla-de...@googlegroups.com
You should redirect using JRoute class instead an string... Also check the docs to see what's for the second parameter of the function.
ie:
$link = JRoute::_('com_mycomp&sectionid=' . $sectionid . '&task=edit&cid[]=' . $id . '&version=' . $v . '', false)
$mainframe->redirect($link, $msg)

Hope it helps

2012/6/30 Alan Sparkes <in...@joomkit.com>

--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To view this discussion on the web, visit https://groups.google.com/d/msg/joomla-dev-general/-/SRnNuXydsBsJ.
To post to this group, send an email to joomla-de...@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-gene...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.

Alan Sparkes

unread,
Jul 3, 2012, 2:03:41 AM7/3/12
to joomla-de...@googlegroups.com
Tried entering just direct url and running thru Jroute.
NO dice.

Interestingly normal Joomla URLs are also being ampersanded. This cant be right......maybe my mamp environment has gone squiffy.
Other admin components do not have this issue.Eg I looked at com_menus and those urls are ok.
I am doing some strange system plugin.
Am going to go over everything with a fine tooth comb....

On Saturday, June 30, 2012 2:50:29 PM UTC+1, Imanol wrote:
You should redirect using JRoute class instead an string... Also check the docs to see what's for the second parameter of the function.
ie:
$link = JRoute::_('com_mycomp&sectionid=' . $sectionid . '&task=edit&cid[]=' . $id . '&version=' . $v . '', false)
$mainframe->redirect($link, $msg)

Hope it helps

I have a plugin which intercepts the request to edit content and redirects to my component controller.

Environemnt
Mamp
php 5.3 / Joomla 2.5.4

It looks like this:

$mainframe = JFactory::getApplication();
//do some checks and then 
 
 $link = 'index.php?option=com_mycomp&sectionid=' . $sectionid . '&task=edit&cid[]=' . $id . '&version=' . $v . '';
        
$mainframe->redirect($link, $msg);

The weird thing is that the redirect url is rendering the '&' as ampersands/entites like '&amp;'

So i get a redirected url from the $mainframe like this:
com_mycomp&amp;sectionid=&amp;task=edit&amp;cid[]=71&amp;version=1
 
So instead of routing to my components edit function it hits a different function altogether! 
If i manually remove the "&amp;" from the url then it hits my edit function.

AM stumped to see how the "&amp;" are getting into the urls.......

Anyone come across this?

Can post more code :)

--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To view this discussion on the web, visit https://groups.google.com/d/msg/joomla-dev-general/-/SRnNuXydsBsJ.
To post to this group, send an email to joomla-dev-general@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-general+unsub...@googlegroups.com.
2012/6/30 Alan Sparkes
I have a plugin which intercepts the request to edit content and redirects to my component controller.

Environemnt
Mamp
php 5.3 / Joomla 2.5.4

It looks like this:

$mainframe = JFactory::getApplication();
//do some checks and then 
 
 $link = 'index.php?option=com_mycomp&sectionid=' . $sectionid . '&task=edit&cid[]=' . $id . '&version=' . $v . '';
        
$mainframe->redirect($link, $msg);

The weird thing is that the redirect url is rendering the '&' as ampersands/entites like '&amp;'

So i get a redirected url from the $mainframe like this:
com_mycomp&amp;sectionid=&amp;task=edit&amp;cid[]=71&amp;version=1
 
So instead of routing to my components edit function it hits a different function altogether! 
If i manually remove the "&amp;" from the url then it hits my edit function.

AM stumped to see how the "&amp;" are getting into the urls.......

Anyone come across this?

Can post more code :)

--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To view this discussion on the web, visit https://groups.google.com/d/msg/joomla-dev-general/-/SRnNuXydsBsJ.
To post to this group, send an email to joomla-dev-general@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-general+unsub...@googlegroups.com.
2012/6/30 Alan Sparkes
I have a plugin which intercepts the request to edit content and redirects to my component controller.

Environemnt
Mamp
php 5.3 / Joomla 2.5.4

It looks like this:

$mainframe = JFactory::getApplication();
//do some checks and then 
 
 $link = 'index.php?option=com_mycomp&sectionid=' . $sectionid . '&task=edit&cid[]=' . $id . '&version=' . $v . '';
        
$mainframe->redirect($link, $msg);

The weird thing is that the redirect url is rendering the '&' as ampersands/entites like '&amp;'

So i get a redirected url from the $mainframe like this:
com_mycomp&amp;sectionid=&amp;task=edit&amp;cid[]=71&amp;version=1
 
So instead of routing to my components edit function it hits a different function altogether! 
If i manually remove the "&amp;" from the url then it hits my edit function.

AM stumped to see how the "&amp;" are getting into the urls.......

Anyone come across this?

Can post more code :)

--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To view this discussion on the web, visit https://groups.google.com/d/msg/joomla-dev-general/-/SRnNuXydsBsJ.
To post to this group, send an email to joomla-dev-general@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-general+unsub...@googlegroups.com.

Alan Sparkes

unread,
Jul 3, 2012, 6:27:43 PM7/3/12
to joomla-de...@googlegroups.com
Solved: just left a var_dump($object->thing) in the onAfterInitialise function.
Weird but once removed all s well.
Reply all
Reply to author
Forward
0 new messages