MDL-59255 core: Extend test_clean_param_url.

Add rtmp:// test and some more URL validity tests since we made changes in
validateUrlSyntax function.
This commit is contained in:
Ruslan Kabalin
2017-07-18 10:29:07 +01:00
parent b03ffb099e
commit 362be64a2b
+12
View File
@@ -597,12 +597,24 @@ class core_moodlelib_testcase extends advanced_testcase {
public function test_clean_param_url() {
// Test PARAM_URL and PARAM_LOCALURL a bit.
// Valid URLs.
$this->assertSame('http://google.com/', clean_param('http://google.com/', PARAM_URL));
$this->assertSame('http://some.very.long.and.silly.domain/with/a/path/', clean_param('http://some.very.long.and.silly.domain/with/a/path/', PARAM_URL));
$this->assertSame('http://localhost/', clean_param('http://localhost/', PARAM_URL));
$this->assertSame('http://0.255.1.1/numericip.php', clean_param('http://0.255.1.1/numericip.php', PARAM_URL));
$this->assertSame('https://google.com/', clean_param('https://google.com/', PARAM_URL));
$this->assertSame('https://some.very.long.and.silly.domain/with/a/path/', clean_param('https://some.very.long.and.silly.domain/with/a/path/', PARAM_URL));
$this->assertSame('https://localhost/', clean_param('https://localhost/', PARAM_URL));
$this->assertSame('https://0.255.1.1/numericip.php', clean_param('https://0.255.1.1/numericip.php', PARAM_URL));
$this->assertSame('ftp://ftp.debian.org/debian/', clean_param('ftp://ftp.debian.org/debian/', PARAM_URL));
$this->assertSame('/just/a/path', clean_param('/just/a/path', PARAM_URL));
// Invalid URLs.
$this->assertSame('', clean_param('funny:thing', PARAM_URL));
$this->assertSame('', clean_param('http://example.ee/sdsf"f', PARAM_URL));
$this->assertSame('', clean_param('javascript://comment%0Aalert(1)', PARAM_URL));
$this->assertSame('', clean_param('rtmp://example.com/livestream', PARAM_URL));
$this->assertSame('', clean_param('rtmp://example.com/live&foo', PARAM_URL));
$this->assertSame('', clean_param('rtmp://example.com/fms&mp4:path/to/file.mp4', PARAM_URL));
}
public function test_clean_param_localurl() {