From: totten@civicrm.org Date: Fri, 27 Jun 2014 07:32:04 +0000 (-0700) Subject: CRM_Core_Menu::getArrayForPathArgs - Allow page_arguments to include "=" in values X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=3b4339fd5fc6645a60f1d8e6235c4fb8ecbac011;p=civicrm-core.git CRM_Core_Menu::getArrayForPathArgs - Allow page_arguments to include "=" in values --- diff --git a/CRM/Core/Menu.php b/CRM/Core/Menu.php index 79e9dd1ed8..f6a80befb3 100644 --- a/CRM/Core/Menu.php +++ b/CRM/Core/Menu.php @@ -712,7 +712,7 @@ UNION ( $elements = explode(',', $pathArgs); //CRM_Core_Error::debug( 'e', $elements ); foreach ($elements as $keyVal) { - list($key, $val) = explode('=', $keyVal); + list($key, $val) = explode('=', $keyVal, 2); $arr[$key] = $val; } diff --git a/tests/phpunit/CRM/Core/MenuTest.php b/tests/phpunit/CRM/Core/MenuTest.php new file mode 100644 index 0000000000..a1a406e969 --- /dev/null +++ b/tests/phpunit/CRM/Core/MenuTest.php @@ -0,0 +1,45 @@ + string $input, 1 => array $expectedOutput) + //$cases[] = array(NULL, array()); + //$cases[] = array('', array()); + //$cases[] = array('freestanding', array('freestanding' => NULL)); + $cases[] = array('addSequence=1', array('addSequence' => '1')); + $cases[] = array('attachUpload=1', array('attachUpload' => '1')); + $cases[] = array('mode=256', array('mode' => '256')); + $cases[] = array('mode=256,addSequence=1,attachUpload=1', array('mode' => '256', 'addSequence' => '1', 'attachUpload' => 1)); + $cases[] = array('mode=256,urlToSession=a:b:c:d', array( + 'mode' => '256', + 'urlToSession' => array( + array('urlVar' => 'a', 'sessionVar' => 'b', 'type' => 'c', 'default' => 'd'), + ), + )); + $cases[] = array('mode=256,urlToSession=a:b:c:d;z:y:x:w', array( + 'mode' => '256', + 'urlToSession' => array( + array('urlVar' => 'a', 'sessionVar' => 'b', 'type' => 'c', 'default' => 'd'), + array('urlVar' => 'z', 'sessionVar' => 'y', 'type' => 'x', 'default' => 'w'), + ), + )); + $cases[] = array('url=whiz!;.:#=%/|+bang?', array('url' => 'whiz!;.:#=%/|+bang?')); + return $cases; + } + + /** + * @param $inputString + * @param $expectedArray + * @dataProvider pathArguments + */ + function testGetArrayForPathArgs($inputString, $expectedArray) { + $actual = CRM_Core_Menu::getArrayForPathArgs($inputString); + $this->assertEquals($expectedArray, $actual); + } +} \ No newline at end of file