Skip to content

Render image icons in the marker type menu and escape icon markup - #1827

Merged
Azgaar merged 1 commit into
Azgaar:masterfrom
barrulus:fix/icon-markup-escaping
Sep 10, 2026
Merged

Azgaar merged 1 commit into
Azgaar:masterfrom
barrulus:fix/icon-markup-escaping

Conversation

@barrulus

@barrulus barrulus commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

Problem

  1. The "add marker" type menu in the Markers Overview writes each config icon as plain text. A marker type whose icon is an image URL (set via the generation settings or the Icon Selector) lists the URL instead of a picture, and the selector button shows it too after a pick.
  2. Hovering an external-image thumbnail in the Icon Selector leaves the tooltip showing the last emoji's message, because the thumbnails set no tooltip.
  3. Marker and regiment icons are read from the map file and spliced into innerHTML unescaped at ten sites (marker editor, overview rows, markers-in-radius, generation settings, marker renderer, regiment editor, regiments overview, battle screen). A crafted .map with an icon such as "><img src=x onerror=…> executes as soon as the marker editor opens.

Fix

  • Menu entries and the selector button render an <img> for URL icons, matching the overview rows.
  • New isImageIcon in fileUtils.ts, requiring an http://, https:// or data:image/ prefix. It replaces the 18 inline startsWith("http") || startsWith("data:image") checks and the selector's half-anchored URL regex.
  • Every icon interpolation goes through the existing escapeHtml, on both the image and the glyph branch.
  • Selector thumbnails show their own image in the tooltip, and set their background via the backgroundImage property with quotes escaped instead of cssText.

Verification

  • tsc --noEmit clean, Biome clean, 944 unit tests pass (new isImageIcon cases included).
  • Headless Chromium on master + this branch: a type with a data-URI icon renders as an image in the menu and on the selector button; no menu entry contains the text data:image; a thumbnail hover puts the image in the tooltip.
  • Injection test: breakout payloads planted on two markers, a marker type, a regiment and a unit type, then both layers drawn and the overview, editor, settings, regiments overview and Icon Selector opened. Zero injected elements, onerror never fired.

The Markers Overview type menu wrote each config icon as plain text, so
a type whose icon is an image URL listed the URL instead of a picture,
and the selector button did the same after a pick.

Marker and regiment icons come straight from the map file and were
spliced into innerHTML unescaped at ten sites. Add isImageIcon, use it
wherever an icon is tested for being an image, escape the icon at every
interpolation, and tighten the Icon Selector's URL check to the same
http(s)/data:image prefixes. Thumbnails in the selector now show their
own image in the tooltip and set their background via the style property.
@netlify

netlify Bot commented Sep 9, 2026

Copy link
Copy Markdown

Deploy Preview for afmg ready!

Name Link
🔨 Latest commit 653d449
🔍 Latest deploy log https://app.netlify.com/projects/afmg/deploys/6aa1d241ce70510008ca8326
😎 Deploy Preview https://deploy-preview-1827--afmg.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions Bot added the theme: markers-zones Markers / Notes / Zones label Sep 9, 2026
@Azgaar
Azgaar self-requested a review September 10, 2026 09:07
@Azgaar
Azgaar merged commit 1ffd016 into Azgaar:master Sep 10, 2026
7 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in FMG dev board Sep 10, 2026
@barrulus
barrulus deleted the fix/icon-markup-escaping branch September 10, 2026 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

theme: markers-zones Markers / Notes / Zones

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants