Merge pull request 'Skip all urls with schemes different from base_url in rewrite_relative' (#38) from klempin/tt-rss:fix/mailto into master

Reviewed-on: https://git.tt-rss.org/fox/tt-rss/pulls/38
master
fox 3 years ago
commit 34807bacd4

@ -1,5 +1,11 @@
<?php <?php
class UrlHelper { class UrlHelper {
const ALLOWED_RELATIVE_SCHEMES = [
"magnet",
"mailto",
"tel"
];
static $fetch_last_error; static $fetch_last_error;
static $fetch_last_error_code; static $fetch_last_error_code;
static $fetch_last_error_content; static $fetch_last_error_content;
@ -36,8 +42,7 @@ class UrlHelper {
} else if (strpos($rel_url, "//") === 0) { } else if (strpos($rel_url, "//") === 0) {
# protocol-relative URL (rare but they exist) # protocol-relative URL (rare but they exist)
return self::validate("https:" . $rel_url); return self::validate("https:" . $rel_url);
} else if (strpos($rel_url, "magnet:") === 0) { } else if (array_search($rel_parts["scheme"] ?? "", self::ALLOWED_RELATIVE_SCHEMES, true) !== false) {
# allow magnet links
return $rel_url; return $rel_url;
} else { } else {
$base_parts = parse_url($base_url); $base_parts = parse_url($base_url);

Loading…
Cancel
Save