Skip to content

Commit

Permalink
Merge pull request #356 from ANF-Studios/main
Browse files Browse the repository at this point in the history
Check for zip extension before trimming
  • Loading branch information
CodeMyst authored Mar 30, 2021
2 parents e6e6c35 + eb8b3fe commit f38ddae
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions source/pastemyst/web/paste.d
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,13 @@ public class PasteWeb
import pastemyst.db : tryFindOneById, createZip;
import std.path : baseName;

// remove .zip form the id
string id = _id[0..($-".zip".length)];
// remove .zip form the id if present
if (_id.endsWith(".zip"))
{
_id = _id[0..($-".zip".length)];
}

const auto pasteRes = tryFindOneById!Paste(id);
const auto pasteRes = tryFindOneById!Paste(_id);

enforceHTTP(!pasteRes.isNull, HTTPStatus.notFound);

Expand Down

0 comments on commit f38ddae

Please sign in to comment.