Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions components/ILIAS/Data/src/URI.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ class URI
private const UNRESERVED = self::ALPHA_DIGIT . '|[\\-\\._~]';
private const UNRESERVED_NO_DOT = self::ALPHA_DIGIT . '|[\\-_~]';

private const PCHAR = self::UNRESERVED . '|' . self::SUBDELIMS . '|' . self::PCTENCODED . '|:|@';
private const BASEURI_PCHAR = self::UNRESERVED . '|' . self::BASEURI_SUBDELIMS . '|' . self::PCTENCODED . '|:|@';
private const PCHAR = self::UNRESERVED . '|' . self::SUBDELIMS . '|' . self::PCTENCODED;

private const SCHEMA = '#^' . self::ALPHA . '(' . self::ALPHA_DIGIT . '|' . self::PIMP . ')*$#';
private const DOMAIN_LABEL = self::ALPHA_DIGIT . '((' . self::UNRESERVED_NO_DOT . '|' . self::PCTENCODED . '|' . self::BASEURI_SUBDELIMS . ')*' . self::ALPHA_DIGIT . ')*';
Expand Down
26 changes: 17 additions & 9 deletions components/ILIAS/Data/tests/URITest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ class URITest extends TestCase
private const URI_NO_QUERY_1 = 'git://one-letter-top-level.a:8080/someaccount/somerepo/somerepo.git/#fragment';
private const URI_NO_QUERY_2 = 'git://github.com:8080/someaccount/somerepo/somerepo.git#fragment';

private const URI_AUTHORITY_AND_QUERY_1 = 'git://github.com?query_p$,;:A!\'*+()ar_1=val_1&quer?y_par_2=val_2';
private const URI_AUTHORITY_AND_QUERY_2 = 'git://github.com/?qu/ery_p$,;:A!\'*+()ar_1=val_1&quer?y_par_2=val_2';
private const URI_AUTHORITY_AND_QUERY_1 = 'git://github.com?query_p$,;A!\'*+()ar_1=val_1&quer?y_par_2=val_2';
private const URI_AUTHORITY_AND_QUERY_2 = 'git://github.com/?qu/ery_p$,;A!\'*+()ar_1=val_1&quer?y_par_2=val_2';

private const URI_AUTHORITY_AND_FRAGMENT = 'git://github.com:8080/#fragment$,;:A!\'*+()ar_1=val_1&';
private const URI_AUTHORITY_AND_FRAGMENT = 'git://github.com:8080/#fragment$,;A!\'*+()ar_1=val_1&';

private const URI_AUTHORITY_PATH_FRAGMENT = 'git://git$,;hub.com:8080/someacc$,;ount/somerepo/somerepo.git#frag:A!\'*+()arment';
private const URI_AUTHORITY_PATH_FRAGMENT = 'git://git$,;hub.com:8080/someacc$,;ount/somerepo/somerepo.git#fragA!\'*+()arment';

private const URI_PATH = 'git://git$,;hub.com:8080/someacc$,;ount/somerepo/somerepo.git/';

Expand All @@ -58,9 +58,10 @@ class URITest extends TestCase
private const URI_WRONG_AUTHORITY_1 = 'git://git$,;hu<b.com:8080/someacc$,;ount/somerepo/somerepo.git/';
private const URI_WRONG_AUTHORITY_2 = 'git://git$,;hu=b.com/someacc$,;ount/somerepo/somerepo.git/';


private const URI_INVALID = 'https://host.de/ilias.php/"><script>alert(1)</script>?baseClass=ilObjChatroomGUI&cmd=getOSDNotifications&cmdMode=asynch&max_age=15192913';

private const URI_INVALID_CHARACTERS_IN_QUERY = 'git://github.com?query_p=:&query_p2=ilias@ilias.de';

private const URI_FAKEPCENC = 'g+it://github.com:8080/someaccoun%t/somerepo/somerepo.git/?query_par_1=val_1&query_par_2=val_2#fragment';

private const URI_REALPCTENC = 'g+it://github.com:8080/someaccount%2Fsomerepo/som%2brepo.git/?par_lower=val_%2b&par_upper=val_%C3%A1#fragment';
Expand Down Expand Up @@ -250,7 +251,7 @@ public function test_authority_and_query(): void
$this->assertEquals('github.com', $uri->getHost());
$this->assertNull($uri->getPort());
$this->assertNull($uri->getPath());
$this->assertEquals('query_p$,;:A!\'*+()ar_1=val_1&quer?y_par_2=val_2', $uri->getQuery());
$this->assertEquals('query_p$,;A!\'*+()ar_1=val_1&quer?y_par_2=val_2', $uri->getQuery());
$this->assertNull($uri->getFragment());

$uri = new ILIAS\Data\URI(self::URI_AUTHORITY_AND_QUERY_2);
Expand All @@ -259,7 +260,7 @@ public function test_authority_and_query(): void
$this->assertEquals('github.com', $uri->getHost());
$this->assertNull($uri->getPort());
$this->assertNull($uri->getPath());
$this->assertEquals('qu/ery_p$,;:A!\'*+()ar_1=val_1&quer?y_par_2=val_2', $uri->getQuery());
$this->assertEquals('qu/ery_p$,;A!\'*+()ar_1=val_1&quer?y_par_2=val_2', $uri->getQuery());
$this->assertNull($uri->getFragment());
}

Expand All @@ -273,7 +274,7 @@ public function test_authority_and_fragment(): void
$this->assertEquals('8080', $uri->getPort());
$this->assertNull($uri->getPath());
$this->assertNull($uri->getQuery());
$this->assertEquals('fragment$,;:A!\'*+()ar_1=val_1&', $uri->getFragment());
$this->assertEquals('fragment$,;A!\'*+()ar_1=val_1&', $uri->getFragment());
}

#[\PHPUnit\Framework\Attributes\Depends('test_init')]
Expand All @@ -286,7 +287,7 @@ public function test_authority_path_fragment(): void
$this->assertEquals('8080', $uri->getPort());
$this->assertEquals('someacc$,;ount/somerepo/somerepo.git', $uri->getPath());
$this->assertNull($uri->getQuery());
$this->assertEquals('frag:A!\'*+()arment', $uri->getFragment());
$this->assertEquals('fragA!\'*+()arment', $uri->getFragment());
}

#[\PHPUnit\Framework\Attributes\Depends('test_init')]
Expand Down Expand Up @@ -359,6 +360,13 @@ public function test_uri_invalid(): void
new ILIAS\Data\URI(self::URI_INVALID);
}

#[\PHPUnit\Framework\Attributes\Depends('test_init')]
public function test_invalid_characters_in_query(): void
{
$this->expectException(InvalidArgumentException::class);
new ILIAS\Data\URI(self::URI_INVALID_CHARACTERS_IN_QUERY);
}

#[\PHPUnit\Framework\Attributes\Depends('test_init')]
public function test_realpctenc(): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function testTableReadOnly(): void
{
$dummy_gui = new stdClass();

$uri = 'http://myIlias/ilias.php?baseClass=iladministrationgui&cmdNode=2g:qo:gq&cmdClass=ilLegalDocumentsAdministrationGUI&cmd=documents&ref_id=50';
$uri = 'http://myIlias/ilias.php?baseClass=iladministrationgui&cmdNode=2g.qo.gq&cmdClass=ilLegalDocumentsAdministrationGUI&cmd=documents&ref_id=50';

$container = $this->mockTree(Container::class, [
'ui' => [
Expand All @@ -97,7 +97,7 @@ public function testTableEditable(): void

$dummy_gui = new stdClass();

$uri = 'http://myIlias/ilias.php?baseClass=iladministrationgui&cmdNode=2g:qo:gq&cmdClass=ilLegalDocumentsAdministrationGUI&cmd=documents&ref_id=50';
$uri = 'http://myIlias/ilias.php?baseClass=iladministrationgui&cmdNode=2g.qo.gq&cmdClass=ilLegalDocumentsAdministrationGUI&cmd=documents&ref_id=50';

$container = $this->mockTree(Container::class, [
'ui' => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class DocumentTableTest extends TestCase
public function testConstruct(): void
{
$uri = $this->mock(UriInterface::class);
$uri->method('__toString')->willReturn('http://myIlias/ilias.php?baseClass=iladministrationgui&cmdNode=2g:qo:gq&cmdClass=ilLegalDocumentsAdministrationGUI&cmd=documents&ref_id=50');
$uri->method('__toString')->willReturn('http://myIlias/ilias.php?baseClass=iladministrationgui&cmdNode=2g.qo.gq&cmdClass=ilLegalDocumentsAdministrationGUI&cmd=documents&ref_id=50');

$request = $this->mock(ServerRequestInterface::class);
$request->method("getUri")->willReturn($uri);
Expand All @@ -75,7 +75,7 @@ public function testConstruct(): void
public function testCriterionName(): void
{
$uri = $this->mock(UriInterface::class);
$uri->method('__toString')->willReturn('http://myIlias/ilias.php?baseClass=iladministrationgui&cmdNode=2g:qo:gq&cmdClass=ilLegalDocumentsAdministrationGUI&cmd=documents&ref_id=50');
$uri->method('__toString')->willReturn('http://myIlias/ilias.php?baseClass=iladministrationgui&cmdNode=2g.qo.gq&cmdClass=ilLegalDocumentsAdministrationGUI&cmd=documents&ref_id=50');

$request = $this->mock(ServerRequestInterface::class);
$request->method("getUri")->willReturn($uri);
Expand Down
2 changes: 1 addition & 1 deletion components/ILIAS/UI/tests/Component/Link/BulkyLinkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function testGetAction(): void
$with_query = $plain . "?query1=1";
$with_multi_query = $with_query . "&query2=2";
$with_fragment = $plain . "#fragment";
$with_multi_query_and_fragment_uri = $with_multi_query . $with_fragment;
$with_multi_query_and_fragment_uri = $with_multi_query . "#fragment";

$plain_uri = new Data\URI($plain);
$with_query_uri = new Data\URI($with_query);
Expand Down