404 on invalid paste ID

This commit is contained in:
Floorb 2021-08-18 18:06:45 -04:00
parent 77bead92a6
commit a80b325987

View file

@ -57,9 +57,13 @@ $row = $conn->querySelectOne(
// This is used in the theme files. // This is used in the theme files.
$totalpastes = getSiteTotalPastes($conn); $totalpastes = getSiteTotalPastes($conn);
if (!$row) { $notfound = null;
$is_private = false;
if ($row === null) {
header('HTTP/1.1 404 Not Found'); header('HTTP/1.1 404 Not Found');
$notfound = $lang['notfound']; // "Not found"; $notfound = $lang['notfound']; // "Not found";
goto Not_Valid_Paste;
} else { } else {
$paste_title = $row['title']; $paste_title = $row['title'];
$paste_code = $row['code']; $paste_code = $row['code'];
@ -256,7 +260,7 @@ if ($p_password == "NONE" || $p_password === null) {
Not_Valid_Paste: Not_Valid_Paste:
// Private paste not valid // Private paste not valid
if ($is_private == '1') { if ($is_private || $notfound) {
// Display errors // Display errors
require_once('theme/' . $default_theme . '/header.php'); require_once('theme/' . $default_theme . '/header.php');
require_once('theme/' . $default_theme . '/errors.php'); require_once('theme/' . $default_theme . '/errors.php');