From ea27fd8a45818ebb5b1c09a888282c645eabe68b Mon Sep 17 00:00:00 2001
From: dicedtomato <35403473+diced@users.noreply.github.com>
Date: Fri, 8 Jul 2022 02:52:19 +0000
Subject: [PATCH] feat(3.4.8): fix bug where you can crash zipline
---
.gitignore | 3 +--
package.json | 2 +-
src/pages/404.tsx | 32 +++++++++++++++-----------------
src/pages/500.tsx | 30 ++++++++++++++----------------
src/pages/_app.tsx | 1 +
src/pages/_error.tsx | 30 ++++++++++++++----------------
src/server/index.ts | 20 +++++++++++++-------
7 files changed, 59 insertions(+), 59 deletions(-)
diff --git a/.gitignore b/.gitignore
index a7246a6..21e258e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -42,5 +42,4 @@ yarn-error.log*
# zipline
config.toml
uploads/
-dist/
-docker-compose.local.yml
\ No newline at end of file
+dist/
\ No newline at end of file
diff --git a/package.json b/package.json
index e804bf3..15681f5 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "zipline",
- "version": "3.4.7",
+ "version": "3.4.8",
"license": "MIT",
"scripts": {
"dev": "node esbuild.config.js && REACT_EDITOR=code NODE_ENV=development node dist/server",
diff --git a/src/pages/404.tsx b/src/pages/404.tsx
index 1b26df0..991f732 100644
--- a/src/pages/404.tsx
+++ b/src/pages/404.tsx
@@ -1,25 +1,23 @@
import React from 'react';
-import { Box, Button, Stack, Text, Title } from '@mantine/core';
+import { Button, Stack, Title } from '@mantine/core';
import Link from 'components/Link';
import MutedText from 'components/MutedText';
export default function FourOhFour() {
return (
- <>
-
- 404
- This page does not exist!
-
-
- >
+
+ 404
+ This page does not exist!
+
+
);
}
\ No newline at end of file
diff --git a/src/pages/500.tsx b/src/pages/500.tsx
index 0107644..fde6b67 100644
--- a/src/pages/500.tsx
+++ b/src/pages/500.tsx
@@ -5,21 +5,19 @@ import MutedText from 'components/MutedText';
export default function FiveHundred() {
return (
- <>
-
- 500
- Internal Server Error
-
-
- >
+
+ 500
+ Internal Server Error
+
+
);
}
\ No newline at end of file
diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx
index 74ef38c..f3f575c 100644
--- a/src/pages/_app.tsx
+++ b/src/pages/_app.tsx
@@ -9,6 +9,7 @@ export default function MyApp({ Component, pageProps }) {
{Component.title}
+
diff --git a/src/pages/_error.tsx b/src/pages/_error.tsx
index da71805..f46faed 100644
--- a/src/pages/_error.tsx
+++ b/src/pages/_error.tsx
@@ -5,22 +5,20 @@ import MutedText from 'components/MutedText';
export default function Error({ statusCode }) {
return (
- <>
-
- {statusCode}
- Something went wrong...
-
-
- >
+
+ {statusCode}
+ Something went wrong...
+
+
);
}
diff --git a/src/server/index.ts b/src/server/index.ts
index a8b6de4..87f16d3 100644
--- a/src/server/index.ts
+++ b/src/server/index.ts
@@ -65,6 +65,8 @@ async function start() {
});
router.on('GET', config.uploader.route === '/' ? '/:id(^[^\\.]+\\.[^\\.]+)' : `${config.uploader.route}/:id`, async (req, res, params) => {
+ if (params.id === '') return nextServer.render404(req, res as ServerResponse);
+
const image = await prisma.image.findFirst({
where: {
OR: [
@@ -75,13 +77,16 @@ async function start() {
});
if (!image) await rawFile(req, res, nextServer, params.id);
-
- if (image.password) await handle(req, res);
- else if (image.embed) await handle(req, res);
- else await fileDb(req, res, nextServer, prisma, handle, image);
+ else {
+ if (image.password) await handle(req, res);
+ else if (image.embed) await handle(req, res);
+ else await fileDb(req, res, nextServer, prisma, handle, image);
+ }
});
router.on('GET', '/r/:id', async (req, res, params) => {
+ if (params.id === '') return nextServer.render404(req, res as ServerResponse);
+
const image = await prisma.image.findFirst({
where: {
OR: [
@@ -92,9 +97,10 @@ async function start() {
});
if (!image) await rawFile(req, res, nextServer, params.id);
-
- if (image.password) await handle(req, res);
- else await rawFileDb(req, res, nextServer, prisma, image);
+ else {
+ if (image.password) await handle(req, res);
+ else await rawFileDb(req, res, nextServer, prisma, image);
+ }
});
await nextServer.prepare();