sillsdev / sillsdev/libpalaso

Invalid copyright info written to PNG files (we write UTF-8 but spec says ISO-8859-1)

Open
#1,503 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
46
Forks
50
Avg merge
6d 16h
Merged PRs (30d)
7

Description

When adding a picture in FieldWorks 9.3.8.1416, the copyright and license metadata is saved to the PNG file in multiple formats: an XML chunk in XMP format, correctly saved in an iTXt chunk, and two tEXt chunks tagged as "Copyright" and "Author". The two tEXt chunks are written in UTF-8, even though the PNG spec says that tEXt chunks should be encoded in ISO-8859-1. This results in the copyright statement looking like this when I run exiftool test-image.png:

License                         : http://creativecommons.org/licenses/by-sa/4.0/
Rights                          : Copyright © 2026, Robin Munn
Creator                         : Robin Munn
Copyright                       : Copyright © 2026, Robin Munn
Author                          : Robin Munn

Notice the "Copyright © 2026, Robin Munn" line, because the © character (U+00A9) is 0xC2 0xA9 in UTF-8. In ISO-8859-1, 0xC2 is  while 0xA9 is ©.

This might not actually be a bug in SIL.Core.ClearShare; it might be a TagLib bug, where TagLib always writes UTF-8 no matter what the spec says it should write. And there's a comment in https://github.com/sillsdev/libpalaso/blob/fd1cf9c8a356a7b209afdb9834cc78ea614155d9/SIL.Core/ClearShare/MetadataCore.cs#L197-L201 which suggests that this, or something like this, has been a known problem for a while: that comment is from 2012-07-05 in commit 234f37990f14a8acd5dd3cfd86399ebb8d4cc41c.

It's also possible that this not-following-the-spec behavior is something we'll just have to live with, because what if the file's author was named Пётр Ильич Чайковский? (Better known in English as Pyotr Ilyich Tchaikovsky). It's not always possible to write the copyright statement in Latin-1, which is something that the PNG spec authors didn't consider. If we make the author "Пётр Ильич Чайковский (Pyotr Ilyich Tchaikovsky)" and make the copyright holder the same string, then this is how it comes out in exiftool:

License                         : http://creativecommons.org/licenses/by-sa/4.0/
Rights                          : Copyright © 2026, Пётр Ильич Чайковский (Pyotr Ilyich Tchaikovsky)
Creator                         : Пётр Ильич Чайковский (Pyotr Ilyich Tchaikovsky)
Copyright                       : Copyright © 2026, Пётр Ильич Чайковский (Pyotr Ilyich Tchaikovsky)
Author                          : Пётр Ильич Чайковский (Pyotr Ilyich Tchaikovsky)

At least exiftool prints "Rights" and "Creator" (extracted from the UTF-8 encoded XMP in the iTXt chunk) correctly, meaning that the completely-garbled text of the "Copyright" and "Author" lines is not the only source of copyright metadata available. And even the garbled text (which is UTF-8 being read as ISO-8859-1) can be unmangled, by someone who knows what he's doing, to correctly produce the original name.

But whether or not this is a bug in SIL.Core.ClearShare, or something we can't solve but will just have to live with because we want to be able to correctly credit authors whose names are written in non-Latin alphabets, I wanted to at least record my findings so that we'll know why the copyright statement is showing up with © instead of the correct © in PNG files.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read SIL.Core/ClearShare/MetadataCore.cs around lines 197-201 and trace how PNG tEXt and iTXt metadata are written, including the possible TagLib behavior. Reproduce the exiftool output with Latin-1 and non-Latin names, then establish whether a project change is appropriate or the behavior must be documented; completion requires a decided handling and regression coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.