new-game script mangles titles containing $, backticks or <

Aperta Adatta ai principianti
#17 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
76/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
html, node.js, typescript

Direzione di ricerca

Leggi scripts/new-game.mjs insieme a games/_template/main.ts e games/_template/index.html per capire come viene sostituito il titolo e quando vengono scritti i file. Prova la riproduzione indicata, poi esegui npm run typecheck e npm run build. Il lavoro è completato quando i titoli con i caratteri speciali indicati consentono di creare un gioco compilabile oppure vengono rifiutati con un messaggio chiaro prima che venga scritto qualsiasi file.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug good first issue severity: low

Summary

The scaffolder validates the slug but substitutes the title raw into an HTML file and a TypeScript template literal.

Where

  • scripts/new-game.mjs:21, scripts/new-game.mjs:23-29
  • games/_template/main.ts:48, games/_template/index.html:7

Details

.replaceAll('__SLUG__', slug).replaceAll('__TITLE__', title)

A string replacement still interprets $$, $& and similar patterns. A title with a backtick or ${ produces a file that fails tsc; a title with < or & produces invalid HTML. The folder is copied before the registry is written, so a failure in between leaves a half-registered game. Derived from the code; not run.

Steps to reproduce

  1. npm run new-game cash "Cash $$ Grab".
  2. games/cash/index.html says "Cash $ Grab" while the registry has the correct title.

Suggested fix

Use function replacers (replaceAll('__TITLE__', () => escaped)), HTML-escape for .html, and write the title into the template as a JSON.stringify-ed constant. Or restrict titles to a safe character set.

Acceptance criteria

  • Titles with $, backticks, ${, < and & either scaffold a building game or are rejected with a clear message before any file is written

Getting started

  • Relevant files: scripts/new-game.mjs, games/_template/main.ts, games/_template/index.html
  • Run locally: npm install, then npm run dev
  • Checks: npm run typecheck and npm run build (there is no test suite yet)
  • Related docs: README.md

Filed by repo-audit/full-audit at b001f5d. Severity: low. Effort: S. audit-key: bug|scripts/new-game.mjs|replaceAll

Lingua principale
TypeScript
Stelle
3
Fork
3
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di TMHSDigital/GH-Arcade

Tutte le issue di TMHSDigital/GH-Arcade

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.