From a9f398b206cbe5db9cd7d0e289b15b2c1ad95294 Mon Sep 17 00:00:00 2001 From: Musiker15 Date: Tue, 24 Nov 2026 01:34:02 +0100 Subject: [PATCH 1/2] Fix the findings of a full crawl with OpenSpider The image gallery paginated without end. On the last page the "Next" button was only greyed out, its link still pointed one page further, and pages past the end answered 200. A crawler followed that to page 2725 in every category and language. Pages past the end now answer 404, the buttons at either end have no href, and listImages skips the row query once the offset passes the total, so ?page=1e300 no longer ends in a 500. Other fixes from the same crawl: - The report form rendered its heading after the footer, because it read ?url= with useSearchParams behind Suspense. The page now reads it on the server. - Each image page links the report form with its own ?url=, 8,478 addresses in total. The link is nofollow and robots.txt blocks the query variants, the form itself stays crawlable. - Image page titles include the spawn name and get shorter for long labels. "Trailer" was the title of 16 different pages. - An empty gallery category is noindex and no longer says "0 images". - Longer meta descriptions for the legal and bot statistics pages. - Footer: the Tebex credit is gone (nothing is sold through Tebex since the scripts went free), musiker15.de is linked in the page language, and Discord uses the invite address discord.gg redirected to. --- app/[lang]/(site)/report/ReportClient.tsx | 10 ++- app/[lang]/(site)/report/page.tsx | 19 +++--- .../tools/images/[category]/[name]/page.tsx | 6 +- .../(site)/tools/images/[category]/page.tsx | 43 ++++++++++-- app/robots.ts | 15 +++- components/layout/Footer.tsx | 7 +- components/legal/ReportLink.tsx | 5 ++ lib/config.ts | 2 +- lib/i18n.ts | 2 - lib/images.ts | 31 ++++++++- lib/pageSeo.ts | 18 ++--- tests/aboutFigures.test.ts | 2 +- tests/imageListing.test.ts | 68 +++++++++++++++++++ tests/robots.test.ts | 27 ++++++++ 14 files changed, 204 insertions(+), 51 deletions(-) create mode 100644 tests/imageListing.test.ts create mode 100644 tests/robots.test.ts diff --git a/app/[lang]/(site)/report/ReportClient.tsx b/app/[lang]/(site)/report/ReportClient.tsx index 974b4e9..4b51d36 100644 --- a/app/[lang]/(site)/report/ReportClient.tsx +++ b/app/[lang]/(site)/report/ReportClient.tsx @@ -1,7 +1,6 @@ 'use client' import { useState } from 'react' -import { useSearchParams } from 'next/navigation' import { CircleNotch as Loader2, WarningCircle } from '@/components/icons' import { useLang } from '@/components/i18n/LangProvider' @@ -22,15 +21,14 @@ import { LegalFormShell, Field, FormCard, INPUT_CLASS, TEXTAREA_CLASS } from '@/ interface Done { title: string; text: string } -export function ReportClient() { +export function ReportClient({ initialUrl }: { initialUrl: string }) { const { lang } = useLang() - const params = useSearchParams() const t = legalFormTranslations[lang] const tl = layoutTranslations[lang] - // Derived initial value instead of `setState` in an effect: the - // query parameter is already fixed on the first render. - const [contentUrl, setContentUrl] = useState(() => params.get('url') ?? '') + // Initial value from the server, which read `?url=`: no `setState` in an + // effect, and no client-only render that pushed the heading behind the footer. + const [contentUrl, setContentUrl] = useState(initialUrl) const [reason, setReason] = useState('') const [name, setName] = useState('') const [email, setEmail] = useState('') diff --git a/app/[lang]/(site)/report/page.tsx b/app/[lang]/(site)/report/page.tsx index 6e2450f..bc55960 100644 --- a/app/[lang]/(site)/report/page.tsx +++ b/app/[lang]/(site)/report/page.tsx @@ -1,6 +1,4 @@ import type { Metadata } from 'next' -import { Suspense } from 'react' - import { alternatesFor } from '@/lib/seo' import { pageSeo } from '@/lib/pageSeo' import { getRequestLang } from '@/lib/serverLang' @@ -16,12 +14,13 @@ export async function generateMetadata(): Promise { } } -export default function ReportPage() { - // `useSearchParams` (the prefilled URL) needs a Suspense boundary, - // otherwise Next refuses to build the page. - return ( - - - - ) +type Search = Promise<{ url?: string | string[] }> + +export default async function ReportPage({ searchParams }: { searchParams: Search }) { + // The prefilled URL is read here, on the server. Until 24.11.2026 the form + // read it with `useSearchParams` behind a Suspense boundary, so the server + // sent the footer first and streamed the heading and the form in after it: + // the page's h1 came after four h2 in the HTML. + const { url } = await searchParams + return } diff --git a/app/[lang]/(site)/tools/images/[category]/[name]/page.tsx b/app/[lang]/(site)/tools/images/[category]/[name]/page.tsx index 32eda72..9bdf527 100644 --- a/app/[lang]/(site)/tools/images/[category]/[name]/page.tsx +++ b/app/[lang]/(site)/tools/images/[category]/[name]/page.tsx @@ -12,7 +12,7 @@ import { Card } from '@/components/ui/Card' import { alternatesFor } from '@/lib/seo' import { getRequestLang } from '@/lib/serverLang' import { imagesTranslations, type Lang } from '@/lib/i18n' -import { getImage, getNeighbours, listCategories } from '@/lib/images' +import { getImage, getNeighbours, imageTitle, listCategories } from '@/lib/images' import { absoluteUrl } from '@/lib/siteUrl' import { publicPath } from '@/lib/routes' @@ -33,9 +33,7 @@ export async function generateMetadata({ params }: { params: Params }): Promise< if (!image) return {} const display = image.label || image.name - const title = lang === 'de' - ? `${display} Bild, freigestellt (PNG)` - : `${display} image, transparent PNG` + const title = imageTitle(image, lang) const description = lang === 'de' ? `Freigestelltes ${display}-Bild aus GTA V, ${image.width} mal ${image.height} Pixel, kostenlos für FiveM-Scripts. Direkt über die CDN-URL nutzbar.` : `Transparent ${display} image from GTA V, ${image.width} by ${image.height} pixels, free for FiveM scripts. Use the CDN URL directly.` diff --git a/app/[lang]/(site)/tools/images/[category]/page.tsx b/app/[lang]/(site)/tools/images/[category]/page.tsx index afef539..2685826 100644 --- a/app/[lang]/(site)/tools/images/[category]/page.tsx +++ b/app/[lang]/(site)/tools/images/[category]/page.tsx @@ -45,6 +45,20 @@ export async function generateMetadata({ params }: { params: Params }): Promise< ? `Logos, banners and brand graphics by MSK Scripts. Original works, free to use where they refer to MSK Scripts, not as your own logo.` : `${category.count} transparent GTA V ${category.name.toLowerCase()} images, named by spawn name. Free for FiveM scripts, served from our CDN.` + // A category without a published image is a page with nothing on it. It + // stays reachable, so a link to it does not break, but it stays out of the + // index, with a description that does not start with "0 images". + if (category.count === 0) { + return { + title, + description: lang === 'de' + ? `In dieser Kategorie ist noch kein Bild veröffentlicht. Die anderen Kategorien der Bildergalerie sind frei für FiveM-Scripts nutzbar.` + : `No image has been published in this category yet. The other categories of the image gallery are free to use in FiveM scripts.`, + robots: { index: false, follow: true }, + alternates: alternatesFor(lang, `/tools/images/${slug}`), + } + } + return { title, description, alternates: alternatesFor(lang, `/tools/images/${slug}`) } } @@ -59,9 +73,13 @@ export default async function CategoryPage( const category = await findCategory(slug, lang) if (!category) notFound() - const page = Math.max(1, Number(rawPage) || 1) + const page = Math.max(1, Math.floor(Number(rawPage)) || 1) const result = await listImages({ category: slug, q, page, per: DEFAULT_PER_PAGE }) const pages = Math.max(1, Math.ceil(result.total / result.per)) + // A page past the end answers 404. Until 24.11.2026 it answered 200 with a + // "Next" link, and a crawler followed that to page 2725 in every category + // and language, more than 21,000 addresses. + if (page > pages) notFound() const num = (n: number) => new Intl.NumberFormat(lang === 'de' ? 'de-DE' : 'en-US').format(n) @@ -131,15 +149,26 @@ export default async function CategoryPage( {pages > 1 && ( )} diff --git a/app/robots.ts b/app/robots.ts index 014afc1..2f736fb 100644 --- a/app/robots.ts +++ b/app/robots.ts @@ -32,12 +32,23 @@ const BLOCKED = [ '/discord/giveaway-bot/g/', ] +/** + * Pages whose query variants are blocked, not the page itself. The report + * form is linked from every image with its own `?url=` (8,478 addresses in the + * crawl of 24.11.2026), all with `/report` as canonical. The form itself stays + * crawlable, `Disallow: /en/report?` only matches addresses with a query. + */ +const QUERY_BLOCKED = ['/report'] + export default function robots(): MetadataRoute.Robots { // What exists only once (API, Auth, Botproxy) gets no prefixed line: under // `/en/` and `/de/` it is a 404, and blocking an address that does not exist // is just noise in a file that someone is supposed to be able to read. - const disallow = BLOCKED.flatMap(p => - isExemptPath(p.replace(/\/$/, '')) ? [p] : LANGS.map(lang => publicPath(lang, p))) + const disallow = [ + ...BLOCKED.flatMap(p => + isExemptPath(p.replace(/\/$/, '')) ? [p] : LANGS.map(lang => publicPath(lang, p))), + ...QUERY_BLOCKED.flatMap(p => LANGS.map(lang => `${publicPath(lang, p)}?`)), + ] return { rules: [ diff --git a/components/layout/Footer.tsx b/components/layout/Footer.tsx index 4acfa5d..c86d565 100644 --- a/components/layout/Footer.tsx +++ b/components/layout/Footer.tsx @@ -210,14 +210,9 @@ export function Footer() {

© {new Date().getFullYear()} MSK Scripts. {t.footer_rights} - - {t.footer_powered_by}{' '} - Tebex - - {t.footer_built_by}{' '} - Musiker15 + Musiker15 diff --git a/components/legal/ReportLink.tsx b/components/legal/ReportLink.tsx index 92fb9b2..d6f68a0 100644 --- a/components/legal/ReportLink.tsx +++ b/components/legal/ReportLink.tsx @@ -25,6 +25,11 @@ export function ReportLink({ path, className }: { path: string; className?: stri return ( { const total = Number(totalRow?.total ?? 0) // LIMIT and OFFSET are inline, because mysql2 does not allow placeholders - // there. Both are forced above, by Math.floor and the caps above, into - // integers within known bounds, so no user value goes into the SQL - // unchecked. + // there. `per` is capped above; the page has no upper cap of its own, so a + // page past the last row stops here and never reaches the SQL. Without this + // `?page=1e300` (or `Infinity`) became `OFFSET 6e+301`, a syntax error and a + // 500, and every page past the end still cost a query. const offset = (page - 1) * per + if (offset >= total) return { total, page, per, items: [] } const rows = await query( `SELECT i.category, i.name, i.label, i.ext, i.width, i.height, i.bytes, i.version, i.tags @@ -239,6 +241,29 @@ export async function listImages(opts: ListOptions): Promise { return { total, page, per, items: rows.map(toRecord) } } +/** + * Longest title body that, with " | MSK Scripts" from the layout template, + * stays inside the 580 px a search result shows. + */ +export const IMAGE_TITLE_MAX = 46 + +/** + * Title of an image page. The spawn name goes in next to the label, because + * labels repeat: "Trailer" stood on 16 vehicle pages, "Sou Cent" on 14, all + * with the same title (crawl of 24.11.2026). Long labels drop the wording + * step by step instead of running past what a search result shows. + */ +export function imageTitle(image: Pick, lang: Lang): string { + const label = image.label?.trim() + const named = label && label.toLowerCase() !== image.name.toLowerCase() + ? `${label} (${image.name})` + : image.name + const candidates = lang === 'de' + ? [`${named}, freigestelltes PNG`, `${named} PNG`, `${image.name} PNG`] + : [`${named}, transparent PNG`, `${named} PNG`, `${image.name} PNG`] + return candidates.find(c => c.length <= IMAGE_TITLE_MAX) ?? image.name +} + export async function getImage(category: string, name: string): Promise { const row = await queryOne( `SELECT category, name, label, ext, width, height, bytes, version, tags diff --git a/lib/pageSeo.ts b/lib/pageSeo.ts index c7b880c..2031018 100644 --- a/lib/pageSeo.ts +++ b/lib/pageSeo.ts @@ -102,34 +102,34 @@ export const PAGE_SEO: Record> = { '/discord/ticket-bot/stats': { en: { title: 'Bot Statistics', - description: 'Anonymous live statistics of the MSK Ticket Bot across all servers.', + description: 'Anonymous live statistics of the MSK Ticket Bot across all Discord servers. No server IDs, usernames or other personal data are shown.', }, de: { title: 'Ticket-Bot-Statistiken', - description: 'Anonyme Live-Zahlen des MSK Ticket Bots über alle Server hinweg.', + description: 'Anonyme Live-Zahlen des MSK Ticket Bots über alle Discord-Server hinweg. Server-IDs, Nutzernamen und andere personenbezogene Daten zeigt die Seite nicht.', }, }, '/discord/giveaway-bot/stats': { en: { title: 'Giveaway Bot Statistics', - description: 'Anonymous live statistics of the MSK Giveaway Bot across all Discord servers.', + description: 'Anonymous live statistics of the MSK Giveaway Bot across all Discord servers. No server IDs, usernames or other personal data are shown.', }, de: { title: 'Giveaway-Bot-Statistiken', - description: 'Anonyme Live-Zahlen des MSK Giveaway Bots über alle Discord-Server hinweg.', + description: 'Anonyme Live-Zahlen des MSK Giveaway Bots über alle Discord-Server hinweg. Server-IDs, Nutzernamen und andere personenbezogene Daten zeigt die Seite nicht.', }, }, '/legal/terms': { - en: { title: 'Terms & Conditions', description: 'Terms and conditions for buying and using MSK Scripts resources.' }, + en: { title: 'Terms & Conditions', description: 'The terms and conditions of MSK Scripts for buying and using its resources. The German version is binding, this page is a translation.' }, de: { title: 'AGB', description: 'Allgemeine Geschäftsbedingungen für den Kauf und die Nutzung der Ressourcen von MSK Scripts.' }, }, '/legal/imprint': { - en: { title: 'Imprint', description: 'Legal notice and contact details for MSK Scripts, Moritz Kohm.' }, - de: { title: 'Impressum', description: 'Anbieterkennzeichnung und Kontaktdaten von MSK Scripts, Moritz Kohm.' }, + en: { title: 'Imprint', description: 'Legal notice of MSK Scripts under § 5 DDG: provider, postal address and contact details of Moritz Kohm in Edingen-Neckarhausen.' }, + de: { title: 'Impressum', description: 'Impressum von MSK Scripts nach § 5 DDG: Anbieter, Anschrift und Kontaktdaten von Moritz Kohm in Edingen-Neckarhausen.' }, }, '/legal/privacy': { - en: { title: 'Privacy Policy', description: 'How MSK Scripts handles personal data, in line with the GDPR.' }, - de: { title: 'Datenschutzerklärung', description: 'Wie MSK Scripts mit personenbezogenen Daten umgeht, nach den Vorgaben der DSGVO.' }, + en: { title: 'Privacy Policy', description: 'How MSK Scripts handles personal data under the GDPR: what is stored, for how long, who receives it and which rights you have.' }, + de: { title: 'Datenschutzerklärung', description: 'Wie MSK Scripts mit personenbezogenen Daten umgeht: was gespeichert wird, wie lange, wer es erhält und welche Rechte du nach der DSGVO hast.' }, }, '/legal/withdrawal': { en: { diff --git a/tests/aboutFigures.test.ts b/tests/aboutFigures.test.ts index 0d45939..5593ea9 100644 --- a/tests/aboutFigures.test.ts +++ b/tests/aboutFigures.test.ts @@ -18,7 +18,7 @@ describe('aboutFigures', () => { expect(figures.map(f => f.label)).toEqual(['Mitglieder im Discord', 'Server auf msk_core', 'Doku-Seiten']) const discord = byLabel(figures, 'Discord') expect(discord?.value).toBe('1.627') - expect(discord?.href).toBe('https://discord.gg/5hHSBRHvJE') + expect(discord?.href).toBe('https://discord.com/invite/5hHSBRHvJE') expect(discord?.external).toBe(true) expect(byLabel(aboutFigures('en', 1627, 262, 252), 'Discord')?.value).toBe('1,627') }) diff --git a/tests/imageListing.test.ts b/tests/imageListing.test.ts new file mode 100644 index 0000000..5d039f7 --- /dev/null +++ b/tests/imageListing.test.ts @@ -0,0 +1,68 @@ +import { describe, it, expect, beforeEach, vi } from 'vitest' + +vi.mock('@/lib/db', () => ({ query: vi.fn(), queryOne: vi.fn() })) + +import { query, queryOne } from '@/lib/db' +import { IMAGE_TITLE_MAX, imageTitle, listImages } from '@/lib/images' + +const mQuery = query as unknown as ReturnType +const mQueryOne = queryOne as unknown as ReturnType + +beforeEach(() => { + mQuery.mockReset() + mQueryOne.mockReset() + mQuery.mockResolvedValue([]) +}) + +/** + * The crawl of 24.11.2026 followed "Next" to page 2725 of every category. + * Past the last row nothing reaches the SQL: no wasted query, and no + * `OFFSET 6e+301` from `?page=1e300`, which was a syntax error and a 500. + */ +describe('listImages past the last page', () => { + it('answers an empty page without asking for rows', async () => { + mQueryOne.mockResolvedValue({ total: 159 }) + const result = await listImages({ category: 'weapons', page: 4, per: 60 }) + expect(result.items).toEqual([]) + expect(result.total).toBe(159) + expect(mQuery).not.toHaveBeenCalled() + }) + + it('never puts an exponent or Infinity into the SQL', async () => { + mQueryOne.mockResolvedValue({ total: 159 }) + for (const page of [1e300, Infinity]) { + await listImages({ category: 'weapons', page, per: 60 }) + } + expect(mQuery).not.toHaveBeenCalled() + }) + + it('still reads the last real page', async () => { + mQueryOne.mockResolvedValue({ total: 159 }) + await listImages({ category: 'weapons', page: 3, per: 60 }) + expect(mQuery).toHaveBeenCalledTimes(1) + expect(mQuery.mock.calls[0][0]).toContain('LIMIT 60 OFFSET 120') + }) +}) + +describe('imageTitle', () => { + it('tells pages with the same label apart by spawn name', () => { + const a = imageTitle({ name: 'tanker', label: 'Trailer' }, 'en') + const b = imageTitle({ name: 'tr2', label: 'Trailer' }, 'en') + expect(a).not.toBe(b) + expect(a).toBe('Trailer (tanker), transparent PNG') + }) + + it('does not repeat a label that is just the spawn name', () => { + expect(imageTitle({ name: 'adder', label: 'Adder' }, 'en')).toBe('adder, transparent PNG') + expect(imageTitle({ name: 'adder', label: null }, 'de')).toBe('adder, freigestelltes PNG') + }) + + it('stays inside what a search result shows', () => { + const long = { name: 'acapulcogold_untrimmed_bud', label: 'Acapulco Gold Untrimmed Bud' } + for (const lang of ['en', 'de'] as const) { + const title = imageTitle(long, lang) + expect(title.length).toBeLessThanOrEqual(IMAGE_TITLE_MAX) + expect(title).toContain(long.name) + } + }) +}) diff --git a/tests/robots.test.ts b/tests/robots.test.ts new file mode 100644 index 0000000..e359f63 --- /dev/null +++ b/tests/robots.test.ts @@ -0,0 +1,27 @@ +import { describe, it, expect } from 'vitest' + +import robots from '@/app/robots' + +function disallowed(): string[] { + const rules = robots().rules + const rule = Array.isArray(rules) ? rules[0] : rules + const list = rule.disallow ?? [] + return Array.isArray(list) ? list : [list] +} + +/** + * Every image page links the report form with its own `?url=`; the crawl of + * 24.11.2026 found 8,478 of these addresses. Only the query variants are + * blocked: the form itself is a legal requirement and has to stay reachable. + */ +describe('robots.txt and the report form', () => { + it('blocks the query variants of the report form in both languages', () => { + expect(disallowed()).toEqual(expect.arrayContaining(['/en/report?', '/de/inhalt-melden?'])) + }) + + it('leaves the form itself crawlable', () => { + const list = disallowed() + expect(list).not.toContain('/en/report') + expect(list).not.toContain('/de/inhalt-melden') + }) +}) From 8af758df253240765bc0435f7b3278bc635ae7bc Mon Sep 17 00:00:00 2001 From: Musiker15 Date: Tue, 24 Nov 2026 01:38:56 +0100 Subject: [PATCH 2/2] Name the stored image format in page titles imageTitle said PNG for every image. It now takes the format from the stored extension and only calls a PNG transparent. --- lib/images.ts | 13 +++++++++---- tests/imageListing.test.ts | 16 +++++++++++----- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/lib/images.ts b/lib/images.ts index 7b0a814..3eb8755 100644 --- a/lib/images.ts +++ b/lib/images.ts @@ -253,14 +253,19 @@ export const IMAGE_TITLE_MAX = 46 * with the same title (crawl of 24.11.2026). Long labels drop the wording * step by step instead of running past what a search result shows. */ -export function imageTitle(image: Pick, lang: Lang): string { +export function imageTitle(image: Pick, lang: Lang): string { const label = image.label?.trim() const named = label && label.toLowerCase() !== image.name.toLowerCase() ? `${label} (${image.name})` : image.name - const candidates = lang === 'de' - ? [`${named}, freigestelltes PNG`, `${named} PNG`, `${image.name} PNG`] - : [`${named}, transparent PNG`, `${named} PNG`, `${image.name} PNG`] + // The format comes from the stored file, so a JPEG in `brand` is not + // called a PNG. "transparent" only goes with a PNG. + const format = (image.ext || 'png').toUpperCase() + const isPng = format === 'PNG' + const full = lang === 'de' + ? (isPng ? `${named}, freigestelltes PNG` : `${named}, ${format}`) + : (isPng ? `${named}, transparent PNG` : `${named}, ${format}`) + const candidates = [full, `${named} ${format}`, `${image.name} ${format}`] return candidates.find(c => c.length <= IMAGE_TITLE_MAX) ?? image.name } diff --git a/tests/imageListing.test.ts b/tests/imageListing.test.ts index 5d039f7..6838c10 100644 --- a/tests/imageListing.test.ts +++ b/tests/imageListing.test.ts @@ -46,23 +46,29 @@ describe('listImages past the last page', () => { describe('imageTitle', () => { it('tells pages with the same label apart by spawn name', () => { - const a = imageTitle({ name: 'tanker', label: 'Trailer' }, 'en') - const b = imageTitle({ name: 'tr2', label: 'Trailer' }, 'en') + const a = imageTitle({ name: 'tanker', label: 'Trailer', ext: 'png' }, 'en') + const b = imageTitle({ name: 'tr2', label: 'Trailer', ext: 'png' }, 'en') expect(a).not.toBe(b) expect(a).toBe('Trailer (tanker), transparent PNG') }) it('does not repeat a label that is just the spawn name', () => { - expect(imageTitle({ name: 'adder', label: 'Adder' }, 'en')).toBe('adder, transparent PNG') - expect(imageTitle({ name: 'adder', label: null }, 'de')).toBe('adder, freigestelltes PNG') + expect(imageTitle({ name: 'adder', label: 'Adder', ext: 'png' }, 'en')).toBe('adder, transparent PNG') + expect(imageTitle({ name: 'adder', label: null, ext: 'png' }, 'de')).toBe('adder, freigestelltes PNG') }) it('stays inside what a search result shows', () => { - const long = { name: 'acapulcogold_untrimmed_bud', label: 'Acapulco Gold Untrimmed Bud' } + const long = { name: 'acapulcogold_untrimmed_bud', label: 'Acapulco Gold Untrimmed Bud', ext: 'png' } for (const lang of ['en', 'de'] as const) { const title = imageTitle(long, lang) expect(title.length).toBeLessThanOrEqual(IMAGE_TITLE_MAX) expect(title).toContain(long.name) } }) + + it('names the stored format instead of always saying PNG', () => { + const title = imageTitle({ name: 'banner', label: 'Shop banner', ext: 'jpg' }, 'en') + expect(title).toBe('Shop banner (banner), JPG') + expect(title).not.toContain('PNG') + }) })