Skip to content

Commit ee516ce

Browse files
committed
Validating format now and added view check
1 parent 9285973 commit ee516ce

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

API.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
namespace Piwik\Plugins\OpenApiDocs;
1111

1212
use Piwik\Piwik;
13+
use Piwik\Request;
1314
use Piwik\Plugin\Manager;
1415
use Piwik\Plugins\OpenApiDocs\Specs\SpecGenerator;
1516

@@ -34,6 +35,20 @@ class API extends \Piwik\Plugin\API
3435
*/
3536
public function getMatomoOpenApiSpec(): array
3637
{
38+
39+
Piwik::checkUserHasSomeViewAccess();
40+
41+
$request = Request::fromRequest();
42+
$format = strtolower($request->getStringParameter('format', 'json'));
43+
if (strtolower($format) !== 'json') {
44+
throw new \Exception(
45+
Piwik::translate(
46+
'General_ExceptionInvalidReportRendererFormat',
47+
[$format, 'json']
48+
)
49+
);
50+
}
51+
3752
$filePath = $this->getMatomoSpecFilePath();
3853

3954
if (!$this->isSpecFileReadable($filePath)) {

0 commit comments

Comments
 (0)