forked from ILIAS-eLearning/ILIAS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] 0041321: Character "&" and "ß" in page title in wiki resolving …
…in crash (due to ilCtrl parameter handling, see comments)
- Loading branch information
Showing
6 changed files
with
178 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
components/ILIAS/UICore/classes/class.ilCtrlQueryRegexParser.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of ILIAS, a powerful learning management system | ||
* published by ILIAS open source e-Learning e.V. | ||
* | ||
* ILIAS is licensed with the GPL-3.0, | ||
* see https://www.gnu.org/licenses/gpl-3.0.en.html | ||
* You should have received a copy of said license along with the | ||
* source code, too. | ||
* | ||
* If this is not the case or you just want to try ILIAS, you'll find | ||
* us at: | ||
* https://www.ilias.de | ||
* https://github.com/ILIAS-eLearning | ||
* | ||
*********************************************************************/ | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* @author Fabian Schmid <[email protected]> | ||
*/ | ||
class ilCtrlQueryRegexParser implements ilCtrlQueryParserInterface | ||
{ | ||
private const PATTERN = '/([^=&]*)=([^=&]*)/m'; | ||
|
||
public function parseQueriesOfURL(string $query_string): array | ||
{ | ||
preg_match_all(self::PATTERN, $query_string, $matches, PREG_SET_ORDER, 0); | ||
$query_parameters = []; | ||
foreach ($matches as $match) { | ||
$query_parameters[$match[1]] = $match[2]; | ||
} | ||
|
||
return $query_parameters; | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
components/ILIAS/UICore/interfaces/interface.ilCtrlQueryParserInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of ILIAS, a powerful learning management system | ||
* published by ILIAS open source e-Learning e.V. | ||
* | ||
* ILIAS is licensed with the GPL-3.0, | ||
* see https://www.gnu.org/licenses/gpl-3.0.en.html | ||
* You should have received a copy of said license along with the | ||
* source code, too. | ||
* | ||
* If this is not the case or you just want to try ILIAS, you'll find | ||
* us at: | ||
* https://www.ilias.de | ||
* https://github.com/ILIAS-eLearning | ||
* | ||
*********************************************************************/ | ||
|
||
/** | ||
* @author Fabian Schmid <[email protected]> | ||
*/ | ||
interface ilCtrlQueryParserInterface | ||
{ | ||
/** | ||
* Must return an associative array of key => value pairs from the given query string. | ||
* @param string $query_string | ||
* @return array<string, string> | ||
*/ | ||
public function parseQueriesOfURL(string $query_string): array; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of ILIAS, a powerful learning management system | ||
* published by ILIAS open source e-Learning e.V. | ||
* | ||
* ILIAS is licensed with the GPL-3.0, | ||
* see https://www.gnu.org/licenses/gpl-3.0.en.html | ||
* You should have received a copy of said license along with the | ||
* source code, too. | ||
* | ||
* If this is not the case or you just want to try ILIAS, you'll find | ||
* us at: | ||
* https://www.ilias.de | ||
* https://github.com/ILIAS-eLearning | ||
* | ||
*********************************************************************/ | ||
|
||
declare(strict_types=1); | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* @author Fabian Schmid <[email protected]> | ||
*/ | ||
class ilCtrlQueryParserTest extends TestCase | ||
{ | ||
private ?ilCtrlQueryRegexParser $query_parser = null; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->query_parser = new ilCtrlQueryRegexParser(); | ||
} | ||
|
||
public function queryStringProvider(): array | ||
{ | ||
return [ | ||
[ | ||
'ilias.php?', | ||
[], | ||
], | ||
[ | ||
'ilias.php?ref_id=123&parent_ref_id=456', | ||
[ | ||
'ref_id' => '123', | ||
'parent_ref_id' => '456', | ||
], | ||
], | ||
[ | ||
'ilias.php?param1=some%26value¶m2=other_value', | ||
[ | ||
'param1' => 'some%26value', | ||
'param2' => 'other_value', | ||
] | ||
], | ||
[ | ||
'ilias.php?baseClass=ilwikihandlergui&cmdNode=161:r9:7n:kl&cmdClass=ilnotegui&ref_id=2731&page=Meine_%26_Seite', | ||
[ | ||
'ref_id' => '2731', | ||
'baseClass' => 'ilwikihandlergui', | ||
'cmdNode' => '161:r9:7n:kl', | ||
'cmdClass' => 'ilnotegui', | ||
'page' => 'Meine_%26_Seite', | ||
] | ||
], | ||
[ | ||
'ilias.php?baseClass=ilwikihandlergui&cmdNode=161:r9:164&cmdClass=ilwikipagegui&cmd=whatLinksHere&ref_id=2731&page=Meine_%26_Seite', | ||
[ | ||
'ref_id' => '2731', | ||
'baseClass' => 'ilwikihandlergui', | ||
'cmdNode' => '161:r9:164', | ||
'cmdClass' => 'ilwikipagegui', | ||
'cmd' => 'whatLinksHere', | ||
'page' => 'Meine_%26_Seite', | ||
] | ||
], | ||
[ | ||
'ilias.php?baseClass=ilwikihandlergui&cmdNode=161:r9:164:7n:128&cmdClass=iltagginggui&ref_id=2731&page=Meine_%26_Seite&cmdMode=asynch', | ||
[ | ||
'ref_id' => '2731', | ||
'baseClass' => 'ilwikihandlergui', | ||
'cmdNode' => '161:r9:164:7n:128', | ||
'cmdClass' => 'iltagginggui', | ||
'page' => 'Meine_%26_Seite', | ||
'cmdMode' => 'asynch', | ||
] | ||
], | ||
]; | ||
} | ||
|
||
/** | ||
* @dataProvider queryStringProvider | ||
*/ | ||
public function testQueryParser(string $query_string, array $expected_queries): void | ||
{ | ||
$parsed_queries = $this->query_parser->parseQueriesOfURL($query_string); | ||
$this->assertEquals($expected_queries, $parsed_queries); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters