Skip to content

Commit

Permalink
issue_139: check invalid url
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Nguyen committed May 28, 2020
1 parent 55fa243 commit ea1cc68
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions classes/robot/crawler.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,11 @@ public function mark_for_crawl($baseurl, $url, $courseid = null, $priority = TOO
global $DB, $CFG;

$url = $this->absolute_url($baseurl, $url);
$url = clean_param($url, PARAM_URL);

if (empty($url)) {
return false;
}

// Strip priority from indirect child nodes. Only parent and direct children
// of parent nodes have priority applied to avoid recursively applying priority
Expand Down
10 changes: 10 additions & 0 deletions tests/phpunit/robot_crawler_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,16 @@ public function test_uri_escaping() {
self::assertRegExp($expectedpattern, $page);
}

/**
* Test for checking invalid url
*/
public function test_invalid_url() {
$baseurl = 'http://';
$relativeurl = '<invalidurl>';
$result = $this->robot->mark_for_crawl($baseurl, $relativeurl);
self::assertEquals(false, $result);
}

/**
* Regression test for an issue similar to Issue #48: redirection URI must be escaped when it is output to an HTML document.
*/
Expand Down

0 comments on commit ea1cc68

Please sign in to comment.