Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Giehl <stefan@matomo.org>2021-03-10 11:40:51 +0300
committerGitHub <noreply@github.com>2021-03-10 11:40:51 +0300
commitc753825478c52a132fdb1871af4283acea565dd2 (patch)
tree62c13ebfd0f594ad212016a4242e33660da548e7 /plugins/API
parenta8da26394b2e76742c25d16eaac5c7bda0377bda (diff)
Only allow valid hosts for prefixUrl in API listing (#17315)
* Only allow valid hosts for prefixUrl in API listing * remove error suppression * additionally check for empty hostname
Diffstat (limited to 'plugins/API')
-rw-r--r--plugins/API/Controller.php3
1 files changed, 2 insertions, 1 deletions
diff --git a/plugins/API/Controller.php b/plugins/API/Controller.php
index 585cb14ba9..2fb196d291 100644
--- a/plugins/API/Controller.php
+++ b/plugins/API/Controller.php
@@ -64,7 +64,8 @@ class Controller extends \Piwik\Plugin\Controller
$ApiDocumentation = new DocumentationGenerator();
$prefixUrls = Common::getRequestVar('prefixUrl', 'https://demo.matomo.org/', 'string');
- if (!UrlHelper::isLookLikeUrl($prefixUrls) || strpos($prefixUrls, 'http') !== 0) {
+ $hostname = parse_url($prefixUrls, PHP_URL_HOST);
+ if (empty($hostname) || !UrlHelper::isLookLikeUrl($prefixUrls) || strpos($prefixUrls, 'http') !== 0 || !Url::isValidHost($hostname)) {
$prefixUrls = '';
}
return $ApiDocumentation->getApiDocumentationAsStringForDeveloperReference($outputExampleUrls = true, $prefixUrls);