Skip to content

Fix image metadata on Thai-locale computers (BL-16926) - #8413

Merged
hatton merged 1 commit into
Version6.4from
BL-16926-thai-image-metadata
Sep 29, 2026
Merged

hatton merged 1 commit into
Version6.4from
BL-16926-thai-image-metadata

Conversation

@andrew-polk

@andrew-polk andrew-polk commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Problem. On a computer whose regional format is Thai (probably Lao too), every Bloom operation that reads or writes the credits/license metadata inside an image fails with UnsupportedFormatException. That covers choosing a picture, editing its credits, anything that saves images with metadata, and every book's cover thumbnail: selecting a book replaces its thumbnail with the hazard sign (BL-16944; in a debug build it trips an assert and Bloom exits). The culture sweep's th-TH leg found it. Targets Version6.4.

Cause. When TagLib# isn't given a mime type, it works one out from the file name with a culture-sensitive LastIndexOf("."). Under Thai ICU collation the period is ignorable, so the extension comes out empty and the mime type is taglib/. libpalaso's ClearShare code and Bloom's own code both call TagLib.File.Create(path).

Fix.

  • Bloom registers a TagLib# FileTypeResolver (TagLib's own extension point) at the top of Program.Main. When TagLib's mime type is unknown but the extension found with Path.GetExtension is known, the resolver creates the file with the right mime type. Otherwise it stays out of the way, so mislabeled and unsupported files behave as before. One registration covers libpalaso's calls and Bloom's own direct calls. It can be removed once a TagLib# release searches ordinally (upstream fix: Find the file extension ordinally in File.Create mono/taglib-sharp#381).
  • BloomTests registers it in a [SetUpFixture], as Program does. New th-TH regression tests (PNG and JPEG) cover the libpalaso save/read path and Bloom's RobustFileIO.CreateTaglibFile. They first check that the runtime really ignores the period, so they can't pass for nothing.
  • Verified in a real 6.4 Bloom forced to th-TH: with the resolver disabled, selecting a book wrote the hazard image over its thumbnail; with it enabled, both test books' thumbnails regenerated byte-for-byte identical to the originals.

Ref: https://issues.bloomlibrary.org/youtrack/issue/BL-16926

🤖 Generated with Claude Code

Devin review


This change is Reviewable

@andrew-polk

Copy link
Copy Markdown
Contributor Author

[Claude Opus 5.5 from Andrew Polk's machine during preflight] Consulted Devin on 2026-09-25 22:25 UTC up to commit 8cd8588: no bugs, no flags.

@greptile-apps

greptile-apps Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Retrigger

[Medium risk] Adds a workaround for image metadata handling on Thai-locale systems.

The PR appears safe to merge.

Summary

The PR registers a TagLib# file-type resolver at startup to restore image metadata handling under Thai collation.

  • Adds PNG and JPEG regression tests for metadata reads and writes.
  • Registers the resolver before tests run.

Reviews (3) · Last reviewed commit: "Fix image metadata on Thai-locale comput..."

@andrew-polk

Copy link
Copy Markdown
Contributor Author

[Claude Opus 5.5 from Andrew Polk's machine] Re Greptile's summary: added JPEG cases to both regression tests (amended into 2d22c56). Kept the NLS premise check as a hard failure on purpose: on a runtime whose Thai collation finds the period the tests couldn't reproduce the bug, and a loud failure beats a silent pass. .NET 8 on current Windows uses ICU.

@andrew-polk

Copy link
Copy Markdown
Contributor Author

[Claude Opus 5.5 from Andrew Polk's machine] Consulted Devin on 2026-09-25 23:02 UTC up to commit 2d22c56: no bugs, no flags.

@andrew-polk
andrew-polk marked this pull request as ready for review September 26, 2026 00:11
TagLib# finds a file's extension with a culture-sensitive LastIndexOf, which ignores the period under Thai collation, so every image metadata read/write threw UnsupportedFormatException. Register a TagLib FileTypeResolver at startup that redoes the lookup with Path.GetExtension; it covers libpalaso's calls and Bloom's own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@andrew-polk
andrew-polk force-pushed the BL-16926-thai-image-metadata branch from 2d22c56 to d23dd7c Compare September 29, 2026 16:08
@andrew-polk
andrew-polk changed the base branch from master to Version6.4 September 29, 2026 16:08
@andrew-polk
andrew-polk marked this pull request as draft September 29, 2026 16:08
@andrew-polk

Copy link
Copy Markdown
Contributor Author

[Claude Opus 5.5 from Andrew Polk's machine during preflight] Consulted Devin on 2026-09-29 16:16 UTC up to commit d23dd7c (the fix rebased onto Version6.4): no bugs, no flags.

@andrew-polk
andrew-polk marked this pull request as ready for review September 29, 2026 16:49
@hatton
hatton merged commit cc5b8fb into Version6.4 Sep 29, 2026
2 checks passed
@hatton
hatton deleted the BL-16926-thai-image-metadata branch September 29, 2026 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants