Skip to content

Commit

Permalink
Merge pull request #900 from NeonGamerBot-QK/fix/no-b64-image
Browse files Browse the repository at this point in the history
  • Loading branch information
malted authored Dec 2, 2024
2 parents 3d1f3a8 + dfb05b6 commit a5fcbfd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
22 changes: 22 additions & 0 deletions src/app/harbor/shipyard/new-ship-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,28 @@ export default function NewShipForm({
return
}

if (!screenshotUrl.startsWith('https://')) {
toast({
title: "That screenshot doesn't work!",
description:
'Please use http or https links (no data urls), please host your files in #cdn!',
})
setStaging(false)
return
}
if (
deploymentUrl.includes('localhost') ||
deploymentUrl.includes('127.0.0.1')
) {
toast({
title: "That's not a demo link!",
description:
'Please make sure your link isnt a local link.. Please submit a deployed link instead!',
})
setStaging(false)
return
}

if (readmeUrl.includes('github.com')) {
toast({
title: "This isn't a markdown link!",
Expand Down
8 changes: 7 additions & 1 deletion src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ async function loadShipsCookie(
const ships = await fetchShips(slackId, 3)
response.cookies.set({
name: 'ships',
value: JSON.stringify(ships),
value: JSON.stringify(
ships.map((s) => {
if (s.screenshotUrl.startsWith('data:'))
s.screenshotUrl = `replace_me_with_a_non_dataencoded_url_plz`
return s
}),
),
path: '/',
sameSite: 'strict',
expires: new Date(Date.now() + 5 * 60 * 1000), // In 5 mins
Expand Down

0 comments on commit a5fcbfd

Please sign in to comment.