#1663 set_url_var() - eats "&"'s (includes "patch")

closed-fixed
None
5
2004-11-21
2004-10-25
Marcin Orlowski
No

functions/html.php - set_url_var() inproperly handles
the case where $var precedes other arguments in the
$location chain. In such case we lose "&". Example:

$location is ="foo.php?mailbox=INBOX&smth=1"

set_url_var($location, 'mailbox', 'FOO', false) produces:

"foo.php?mailbox=FOOsmth=1" which invalid result. This
occurs whenever pattern matches 1st or 2nd pattern from
the $pat_a array. In our exampke matched value $v
equals 'INBOX&'. Since we feed new value string
replacement takes place. Unfortunately '&' is
considered a part of old value and gets replaced with
the old value - hence the incorrect results! The
solution is to just add:

if( substr($v,-1)=='&' )
$rpl .= '&';

right above these lines:

$pat = "/$k=$v/";
$url = preg_replace($pat,$rpl,$url);

Now it shall works fine ;)

Discussion

    • assigned_to: nobody --> kink
    • status: open --> closed-fixed
     
  • Logged In: YES
    user_id=285765

    Fixed, thanks for reporting and providing a fix!