1
0
mirror of https://github.com/RSS-Bridge/rss-bridge.git synced 2025-01-16 21:58:21 +01:00

fix: disallow non-strings in GET parameters (#2908)

This commit is contained in:
Dag 2022-07-10 19:50:51 +02:00 committed by GitHub
parent 003ab58514
commit c33f84fcc2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 13 deletions

View File

@ -2,18 +2,24 @@
require_once __DIR__ . '/lib/rssbridge.php';
/*
Move the CLI arguments to the $_GET array, in order to be able to use
rss-bridge from the command line
*/
if (isset($argv)) {
parse_str(implode('&', array_slice($argv, 1)), $cliArgs);
$request = array_merge($_GET, $cliArgs);
} else {
$request = $_GET;
}
try {
if (isset($argv)) {
parse_str(implode('&', array_slice($argv, 1)), $cliArgs);
$request = $cliArgs;
} else {
$request = $_GET;
}
foreach ($request as $key => $value) {
if (! is_string($value)) {
http_response_code(400);
print render('error.html.php', [
'title' => '400 Bad Request',
'message' => "Query parameter \"$key\" is not a string.",
]);
exit(1);
}
}
$actionFactory = new ActionFactory();
if (array_key_exists('action', $request)) {

View File

@ -4,7 +4,7 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="RSS-Bridge" />
<title><?= e($title ?? 'RSS-Bridge') ?></title>
<title><?= e($_title ?? 'RSS-Bridge') ?></title>
<link href="static/style.css" rel="stylesheet">
<link rel="icon" type="image/png" href="static/favicon.png">
</head>

View File

@ -1,6 +1,9 @@
<div style="width: 60%; margin: 30px auto">
<h1>Something went wrong</h1>
<h1>
<?= e($title ?? 'Something went wrong') ?>
</h1>
<br>
<?= e($message) ?>
<br>