[PR #704] [MERGED] viewer/studio: escape texture preview URL and format in texture grid cards (VIEWER-STUDIO-TEXTURE-ESCAPE) #744

Closed
opened 2026-11-26 20:18:54 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/704
Author: @kirigayakazima
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/24/2026
Merged by: @ubiquitarianism

Base: main ← Head: fix/viewer-studio-texture-escape


📝 Commits (1)

  • 9280ce0 viewer/studio: escape texture preview URL and format in texture grid cards

📊 Changes

2 files changed (+36 additions, -4 deletions)

View changed files

📝 tests/test_viewer_studio.cjs (+32 -0)
📝 viewer/studio.html (+4 -4)

📄 Description

Claimed in the coordination issue as: VIEWER-STUDIO-TEXTURE-ESCAPE https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7131376751

What and why

In viewer/studio.html (renderTexturesGrid), escapeHtml was applied to t.name, while t.preview (src="...") and t.format (<span>...</span>) were interpolated raw into card.innerHTML in both the initial 80-card batch and the "show all" batch.

A hostile t.preview or t.format string containing quotes/markup (for example "><img src=x onerror=alert(1)>) broke out of the HTML attribute/element and injected elements/event handlers. Escaping both fields with escapeHtml(t.preview) and escapeHtml(t.format) in both batches aligns them with t.name and the model list in renderAccordionList.

Adds a synthetic regression test in tests/test_viewer_studio.cjs covering both preview and format across card 0 (initial batch) and card 80 ("show all" batch). No game files used.

Tested

Windows 11 x64, Node v24.19.0, Python 3.14.7, CPU only, synthetic inputs only (no game files). Commit 9280ce0370ecbfe935a445e8cb125d1bdb9bfccf.

  • node tests/test_viewer_studio.cjs:
    • before the fix in viewer/studio.html: new test fails with injected <img src=x onerror=alert(1)> tag in tagShape(...);
    • with the fix: 12/12 passed, 0 failed.
  • node tests/test_viewer_streaming.cjs: 57/57 passed, 0 failed.
  • python -I tests/test_viewer_cdn_integrity.py: 10 tests, OK.
  • python -I tests/test_ci_registration.py: 15 tests, OK.
  • python -I tests/test_text_write_line_endings.py: 3 tests, OK.
  • python -I scripts/check_no_game_data.py viewer/studio.html tests/test_viewer_studio.cjs and git diff --check: clean (exit 0).

GPUs tested: n/a

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/704 **Author:** [@kirigayakazima](https://github.com/kirigayakazima) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/24/2026 **Merged by:** [@ubiquitarianism](https://github.com/ubiquitarianism) **Base:** `main` ← **Head:** `fix/viewer-studio-texture-escape` --- ### 📝 Commits (1) - [`9280ce0`](https://github.com/ubiquitarianism/leonida/commit/9280ce0370ecbfe935a445e8cb125d1bdb9bfccf) viewer/studio: escape texture preview URL and format in texture grid cards ### 📊 Changes **2 files changed** (+36 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_viewer_studio.cjs` (+32 -0) 📝 `viewer/studio.html` (+4 -4) </details> ### 📄 Description Claimed in the coordination issue as: VIEWER-STUDIO-TEXTURE-ESCAPE https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7131376751 ### What and why In `viewer/studio.html` (`renderTexturesGrid`), `escapeHtml` was applied to `t.name`, while `t.preview` (`src="..."`) and `t.format` (`<span>...</span>`) were interpolated raw into `card.innerHTML` in both the initial 80-card batch and the `"show all"` batch. A hostile `t.preview` or `t.format` string containing quotes/markup (for example `"><img src=x onerror=alert(1)>`) broke out of the HTML attribute/element and injected elements/event handlers. Escaping both fields with `escapeHtml(t.preview)` and `escapeHtml(t.format)` in both batches aligns them with `t.name` and the model list in `renderAccordionList`. Adds a synthetic regression test in `tests/test_viewer_studio.cjs` covering both `preview` and `format` across card 0 (initial batch) and card 80 (`"show all"` batch). No game files used. ### Tested Windows 11 x64, Node v24.19.0, Python 3.14.7, CPU only, synthetic inputs only (no game files). Commit `9280ce0370ecbfe935a445e8cb125d1bdb9bfccf`. - `node tests/test_viewer_studio.cjs`: - before the fix in `viewer/studio.html`: new test fails with injected `<img src=x onerror=alert(1)>` tag in `tagShape(...)`; - with the fix: **12/12 passed, 0 failed**. - `node tests/test_viewer_streaming.cjs`: **57/57 passed, 0 failed**. - `python -I tests/test_viewer_cdn_integrity.py`: **10 tests, OK**. - `python -I tests/test_ci_registration.py`: **15 tests, OK**. - `python -I tests/test_text_write_line_endings.py`: **3 tests, OK**. - `python -I scripts/check_no_game_data.py viewer/studio.html tests/test_viewer_studio.cjs` and `git diff --check`: clean (exit `0`). GPUs tested: n/a AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:18:54 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#744
No description provided.