feat(3.4.8): fix bug where you can crash zipline

This commit is contained in:
dicedtomato 2022-07-08 02:52:19 +00:00 committed by GitHub
parent 38eef3f0ad
commit ea27fd8a45
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 59 additions and 59 deletions

1
.gitignore vendored
View file

@ -43,4 +43,3 @@ yarn-error.log*
config.toml
uploads/
dist/
docker-compose.local.yml

View file

@ -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",

View file

@ -1,11 +1,10 @@
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 (
<>
<Stack
sx={{
display: 'flex',
@ -20,6 +19,5 @@ export default function FourOhFour() {
<MutedText sx={{ fontSize: 40, fontWeight: 500 }}>This page does not exist!</MutedText>
<Button component={Link} href='/dashboard'>Head to the Dashboard</Button>
</Stack>
</>
);
}

View file

@ -5,7 +5,6 @@ import MutedText from 'components/MutedText';
export default function FiveHundred() {
return (
<>
<Stack
sx={{
display: 'flex',
@ -20,6 +19,5 @@ export default function FiveHundred() {
<MutedText sx={{ fontSize: 40, fontWeight: 500 }}>Internal Server Error</MutedText>
<Button component={Link} href='/dashboard'>Head to the Dashboard</Button>
</Stack>
</>
);
}

View file

@ -9,6 +9,7 @@ export default function MyApp({ Component, pageProps }) {
<Provider store={store}>
<Head>
<title>{Component.title}</title>
<meta name='viewport' content='minimum-scale=1, initial-scale=1, width=device-width' />
</Head>
<ZiplineTheming Component={Component} pageProps={pageProps} />
</Provider>

View file

@ -5,7 +5,6 @@ import MutedText from 'components/MutedText';
export default function Error({ statusCode }) {
return (
<>
<Stack
sx={{
display: 'flex',
@ -20,7 +19,6 @@ export default function Error({ statusCode }) {
<MutedText sx={{ fontSize: 40, fontWeight: 500 }}>Something went wrong...</MutedText>
<Button component={Link} href='/dashboard'>Head to the Dashboard</Button>
</Stack>
</>
);
}

View file

@ -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);
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);
else {
if (image.password) await handle(req, res);
else await rawFileDb(req, res, nextServer, prisma, image);
}
});
await nextServer.prepare();