[PR #2105] gallery: serve PNG thumbnails for textures saved as upper.DDS #2113

Open
opened 2026-11-26 21:20:05 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2105
Author: @Tyrannys
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: gallery-uppercase-dds


📝 Commits (4)

  • e3ac427 gallery: serve PNG thumbnails for textures saved as upper.DDS
  • 831abc1 gallery: the uppercase DDS test also keeps realpath from fixing the case
  • 64671a8 gallery: the case-insensitive DDS sibling goes through safe_subpath
  • 2f06e1e Merge remote-tracking branch 'upstream/main' into gallery-uppercase-dds

📊 Changes

2 files changed (+90 additions, -6 deletions)

View changed files

📝 tests/test_gallery.py (+65 -6)
📝 tools/gallery.py (+25 -0)

📄 Description

Claimed in the coordination issue as: GALLERY-THUMB-UPPERCASE-DDS (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7174150654)

What and why

From CrazyThiago's finding in the coordination issue: tools/gallery.py answers /textures/<stem>.png with a PNG made from <stem>.dds when no PNG exists, but it only tried the lowercase .dds name. On a case-sensitive filesystem a texture saved as upper.DDS is not upper.dds, so the catalog listed it and its thumbnail was a 404.

When <stem>.dds is not a file, the handler now looks in the same folder for a file whose name matches it in any case (dds_sibling). The candidate is the path safe_subpath already resolved inside the textures folder, and the sibling is in that same folder, so the containment guarantee is unchanged. A name that matches nothing in any case is still a 404.

The regression test makes os.path.isfile case-sensitive and stops os.path.realpath from correcting the name's case. On Windows realpath returns the real case (upper.DDS for upper.dds), which is why a test that only patched isfile passed without the fix.

Tested

  • python -I tests/test_gallery.py: 32 tests OK with the fix; on main's tools/gallery.py the new test fails (HTTP Error 404: Texture not found, 1 error of 32).
  • python -I tests/test_text_write_line_endings.py: 3 tests OK.
  • python -I scripts/check_no_game_data.py tools/gallery.py tests/test_gallery.py: clean.

Run on Windows 11, Python 3.14.

GPUs tested: n/a (CPU-only Python tests)

AI-assisted: yes (Claude Code)

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)

🤖 Generated with Claude Code


🔄 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/2105 **Author:** [@Tyrannys](https://github.com/Tyrannys) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `gallery-uppercase-dds` --- ### 📝 Commits (4) - [`e3ac427`](https://github.com/ubiquitarianism/leonida/commit/e3ac427e292fc07858f4d9023d7e5f3dcb0eb167) gallery: serve PNG thumbnails for textures saved as upper.DDS - [`831abc1`](https://github.com/ubiquitarianism/leonida/commit/831abc1c1f9fc42ef811ef08609442379bf99949) gallery: the uppercase DDS test also keeps realpath from fixing the case - [`64671a8`](https://github.com/ubiquitarianism/leonida/commit/64671a8a7462cf30993cb5c17951f0b6550a504a) gallery: the case-insensitive DDS sibling goes through safe_subpath - [`2f06e1e`](https://github.com/ubiquitarianism/leonida/commit/2f06e1eebd5cedea1c27942b76bcf382b2733b60) Merge remote-tracking branch 'upstream/main' into gallery-uppercase-dds ### 📊 Changes **2 files changed** (+90 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_gallery.py` (+65 -6) 📝 `tools/gallery.py` (+25 -0) </details> ### 📄 Description Claimed in the coordination issue as: GALLERY-THUMB-UPPERCASE-DDS (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7174150654) ### What and why From CrazyThiago's finding in the coordination issue: `tools/gallery.py` answers `/textures/<stem>.png` with a PNG made from `<stem>.dds` when no PNG exists, but it only tried the lowercase `.dds` name. On a case-sensitive filesystem a texture saved as `upper.DDS` is not `upper.dds`, so the catalog listed it and its thumbnail was a 404. When `<stem>.dds` is not a file, the handler now looks in the same folder for a file whose name matches it in any case (`dds_sibling`). The candidate is the path `safe_subpath` already resolved inside the textures folder, and the sibling is in that same folder, so the containment guarantee is unchanged. A name that matches nothing in any case is still a 404. The regression test makes `os.path.isfile` case-sensitive and stops `os.path.realpath` from correcting the name's case. On Windows `realpath` returns the real case (`upper.DDS` for `upper.dds`), which is why a test that only patched `isfile` passed without the fix. ### Tested - `python -I tests/test_gallery.py`: 32 tests OK with the fix; on `main`'s `tools/gallery.py` the new test fails (`HTTP Error 404: Texture not found`, 1 error of 32). - `python -I tests/test_text_write_line_endings.py`: 3 tests OK. - `python -I scripts/check_no_game_data.py tools/gallery.py tests/test_gallery.py`: clean. Run on Windows 11, Python 3.14. GPUs tested: n/a (CPU-only Python tests) AI-assisted: yes (Claude Code) ### 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) 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#2113
No description provided.