contao/test — Issue #2462: System::addToUrl() overwrites partials.
Author: importer
Created: 2011-11-29 09:43:11+00:00
State: open
Labels: Feature, framework

The preg_match in addToUrl() unsets partial matches as it only checks if the current key is included in the request string.
Therefore if there is any key in the $strRequest ending with the currently evaluated key, latter one will get unset. This is fatal when having multiple ids in the request like "id" and "specialid".
i.e.:

```
// URL: http://somedomain.de/contao/main.php?do=member&key=manage&id=837
$strSomething = $this->addToUrl('specialid=20');
// $strSomething == 'http://somedomain.de/contao/main.php?do=member&key=manage&specialid=20'
```

I suggest to change the call to detect if it is either the beginning of the string or just after an ampersand or semicolon to have all possible variations taken into account.

```
//if (preg_match('/' . preg_quote($explode[0], '/') . '=/i', $strRequest))
if (preg_match('/(^|&|;)' . preg_quote($explode[0], '/') . '=/i', $strRequest))
```

--- _Originally created by xtra on August 23rd, 2010, at 10:14pm (ID 2462)_