Preview checker: entity names like `&constructor;` decode to function source

Aperta
#356 2 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@amitsinha-cell ci sta già lavorando.

Dal 31/10/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

bug

decodeEntities() in src/lib/meta-fetcher.ts looks names up with NAMED_ENTITIES[body], and NAMED_ENTITIES is a plain object, so names that exist on Object.prototype are found too. A page whose title has one of them shows function source in the preview checker:

parseMetaTags('<title>a &constructor; b</title>', 'https://example.com').title
// "a function Object() { [native code] } b"

&toString;, &hasOwnProperty; and &valueOf; do the same. Browsers leave an unknown name like &constructor; as it is.

What to do

  • Only decode names that are in NAMED_ENTITIES itself, for example with Object.hasOwn(NAMED_ENTITIES, body), or make it a null-prototype object or a Map.

Acceptance criteria

  • &constructor;, &toString;, &hasOwnProperty; and &valueOf; stay as they are, and every entity that decodes today still does
  • A test that fails on the current code
  • npm run check, npm run test and npm run build pass

Want to work on this? Comment below and I'll assign it to you. Please take one issue at a time, branch off dev, and open your PR against dev with Closes #NUM in the description.

Lingua principale
TypeScript
Stelle
8
Fork
4
Merge medio
8h 47m
PR unite (30g)
157

Preparare l'ambiente

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 codercops/ogcops

Tutte le issue di codercops/ogcops

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.