Return 404 if link is invalid; fixes #131

This commit is contained in:
Marius Lindvall 2020-03-24 18:34:29 +01:00
parent 7b7bbb0767
commit 7f21ffb761
2 changed files with 6 additions and 2 deletions

View File

@ -15,6 +15,7 @@ $share = Share::fromShareID($memcache, $_GET["id"]);
// If the link data key is not set, the session probably expired.
if (!$share->exists()) {
header("HTTP/1.1 404 Not Found");
die($LANG['session_invalid']."\n");
} else {
header("Content-Type: text/json");
@ -24,7 +25,10 @@ if (!$share->exists()) {
switch ($share->getType()) {
case SHARE_TYPE_ALONE:
$session = $share->getHost();
if (!$session->exists()) die($LANG['session_invalid']."\n");
if (!$session->exists()) {
header("HTTP/1.1 404 Not Found");
die($LANG['session_invalid']."\n");
}
echo json_encode(array(
"type" => $share->getType(),
"expire" => $share->getExpirationTime(),

View File

@ -258,7 +258,7 @@ function getJSON(url, callback, invalid) {
if (this.readyState == 4) {
var offlineE = document.getElementById("offline");
var notchE = document.getElementById("notch");
if (this.status === 200) {
if (this.status === 200 || this.status === 404) {
// Request successful. Reset offline state and parse the JSON.
knownOffline = false;
if (offlineE !== null) {