}
$host = idn_to_utf8(strtolower(urldecode($host)));
+ if ($host === false) {
+ return false;
+ }
+
// Remove brackets from IPv6 addresses
if (str_starts_with($host, '[') && str_ends_with($host, ']')) {
$host = substr($host, 1, -1);
['https://service.localhost'],
['!@#$', true], // test invalid url
['https://normal.host.com'],
+ ['https://com.one-.nextcloud-one.com'],
];
}
);
}
- public function testValid(): void {
- $host = 'nextcloud.com';
+ public function dataValid(): array {
+ return [
+ ['nextcloud.com', true],
+ ['com.one-.nextcloud-one.com', false],
+ ];
+ }
+
+ /**
+ * @dataProvider dataValid
+ */
+ public function testValid(string $host, bool $expected): void {
$this->hostnameClassifier
->method('isLocalHostname')
->with($host)
$valid = $this->validator->isValid($host);
- self::assertTrue($valid);
+ self::assertSame($expected, $valid);
}
public function testLocalHostname(): void {