Skip to content

Conversation

jpmsousa03
Copy link
Contributor

Summary

  • This is a…

    • Bug fix
    • Feature addition
    • Refactoring
    • Minor/simple change (e.g., a typo)
    • Other
  • Description (1-2 sentences):
    A change has been applied to mp4.py, ensuring that _casemap is checked before applying pre-mappings. This prevents duplicate tags from being saved in the file.


Problem

Although _casemap correctly stores the capitalization of a tag when loading, an issue arises if a stored tag (e.g., ----:com.apple.iTunes:Label) shares the same internal Picard tag as one of the pre-mapped cases (e.g., label). In such cases, the internal tag would be converted to the pre-mapped format (e.g., ----:com.apple.iTunes:LABEL) when saving. This leads to duplicate tags in the saved file.


Solution

The fix prioritizes maintaining the original tag capitalization. When saving or deleting a tag, _casemap is checked before applying the pre-mapped cases.


Action

Additional actions required:

<eading to data being persistent or being duplicated. In my fix, casemap is checked before the pre-mappings, avoiding the wrong behaviour.
@zas zas requested a review from phw April 1, 2025 08:06
Copy link
Member

@phw phw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the bugfix. This looks sensible and should work.

But I'd like to test this some more and make sure the change does not have other side effects. Changing the order of tag processing could easily break some other case.

I'm currently low on time, hence it will take a couple of days until I get to testing this change fully.

@jpmsousa03
Copy link
Contributor Author

Sure! Let me know if I can help with anything. I'll also keep testing to check if there are any case where the processing might break.

Copy link
Member

@phw phw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot. I checked this, and I can't see that it would break anything. General change is good o go, I just have two minor stylistic comments.

And sorry for the longer delay, last two weeks didn't exactly turn out as expected for me.

@jpmsousa03 jpmsousa03 requested a review from phw April 12, 2025 22:54
Copy link
Member

@phw phw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks a lot. LGTM

As a side note I wonder whether we need something similar for ID3. I haven't checked the code yet, but it might have the same issue.

@phw phw enabled auto-merge (squash) April 13, 2025 05:25
@phw phw merged commit f2849d2 into metabrainz:master Apr 13, 2025
50 checks passed
@phw phw added the Bug fix label Apr 13, 2025
@jpmsousa03
Copy link
Contributor Author

Thanks! I'm not sure if it happens in ID3 as well, I haven’t looked at the ID3 code yet, but I might take a look when I get some time.

phw pushed a commit that referenced this pull request Jun 27, 2025
Fix #3029: incorrect mapping of case-variant tags in MP4 files

<eading to data being persistent or being duplicated. In my fix, casemap is checked before the pre-mappings, avoiding the wrong behaviour.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants