commit
e9ef7c0ecd
3 changed files with 14 additions and 2 deletions
5
.github/PULL_REQUEST_TEMPLATE.md
vendored
5
.github/PULL_REQUEST_TEMPLATE.md
vendored
|
@ -21,6 +21,11 @@ Happy contributing!
|
||||||
|
|
||||||
(If this PR is related to any other PR or resolves any issue or related to any issue link all related PR and issues here.)
|
(If this PR is related to any other PR or resolves any issue or related to any issue link all related PR and issues here.)
|
||||||
|
|
||||||
|
### Have you added your change to the [Changelog](https://github.com/appwrite/appwrite/blob/master/CHANGES.md)?
|
||||||
|
|
||||||
|
(The CHANGES.md file tracks all the changes that make it to the `main` branch. Add your change to this file in the following format)
|
||||||
|
- One line description of your PR [#pr_number](Link to your PR)
|
||||||
|
|
||||||
### Have you read the [Contributing Guidelines on issues](https://github.com/appwrite/appwrite/blob/master/CONTRIBUTING.md)?
|
### Have you read the [Contributing Guidelines on issues](https://github.com/appwrite/appwrite/blob/master/CONTRIBUTING.md)?
|
||||||
|
|
||||||
(Write your answer here.)
|
(Write your answer here.)
|
||||||
|
|
|
@ -49,11 +49,17 @@ class URL extends Validator
|
||||||
*/
|
*/
|
||||||
public function isValid($value): bool
|
public function isValid($value): bool
|
||||||
{
|
{
|
||||||
if (\filter_var($value, FILTER_VALIDATE_URL) === false) {
|
$sanitizedURL = '';
|
||||||
|
|
||||||
|
foreach (str_split($value) as $character) {
|
||||||
|
$sanitizedURL .= (ord($character) > 127) ? rawurlencode($character) : $character;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (\filter_var($sanitizedURL, FILTER_VALIDATE_URL) === false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($this->allowedSchemes) && !\in_array(\parse_url($value, PHP_URL_SCHEME), $this->allowedSchemes)) {
|
if (!empty($this->allowedSchemes) && !\in_array(\parse_url($sanitizedURL, PHP_URL_SCHEME), $this->allowedSchemes)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,7 @@ class URLTest extends TestCase
|
||||||
$this->assertEquals(false, $this->url->isValid('htt@s://example.com'));
|
$this->assertEquals(false, $this->url->isValid('htt@s://example.com'));
|
||||||
$this->assertEquals(true, $this->url->isValid('http://www.example.com/foo%2\u00c2\u00a9zbar'));
|
$this->assertEquals(true, $this->url->isValid('http://www.example.com/foo%2\u00c2\u00a9zbar'));
|
||||||
$this->assertEquals(true, $this->url->isValid('http://www.example.com/?q=%3Casdf%3E'));
|
$this->assertEquals(true, $this->url->isValid('http://www.example.com/?q=%3Casdf%3E'));
|
||||||
|
$this->assertEquals(true, $this->url->isValid('https://example.com/foo%2\u00c2\u00ä9zbär'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIsValidAllowedSchemes(): void
|
public function testIsValidAllowedSchemes(): void
|
||||||
|
|
Loading…
Reference in a new issue