Skip to content

Obey relevant max_length when importing strings from the XPI#24713

Merged
diox merged 4 commits intomozilla:masterfrom
diox:obey-max-length-when-importing-strings-from-xpi
Apr 8, 2026
Merged

Obey relevant max_length when importing strings from the XPI#24713
diox merged 4 commits intomozilla:masterfrom
diox:obey-max-length-when-importing-strings-from-xpi

Conversation

@diox
Copy link
Copy Markdown
Member

@diox diox commented Apr 7, 2026

Fixes: mozilla/addons#15268

Linter validation isn't applied correctly for localized strings, and no validation is applied to the description field (which becomes the summary in AMO). This silently truncates the strings when importing manifest data to avoid inconsistent data and errors that are difficult for developers to recover from themselves.

Testing

  • Uploading an extension with a description of more than 250 characters in the manifest
  • Uploading an extension with a translation for the name in the manifest of more than 50 characters
  • Uploading an extension with a translation for the description in the manifest of more than 250 characters
  • The above, but with a (otherwise valid) default_locale in the manifest pointing to a locale that has no messages.json (or an incomplete one) in the xpi
  • The above, but with an invalid default_locale in the manifest

For all these cases, if the string goes over the max for the field, the value should be silently truncated. The linter may rise proper errors for these cases in the future (See mozilla/addons-linter#4910 for instance)

@diox diox requested a review from eviljeff April 7, 2026 19:48
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's unfortunate there isn't a more optimal way of implementing this - we're doing essentially the same retrieval of max length and string slicing in 3 different places.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, the whole thing really needs a deeper refactor. Next time...

@diox diox merged commit fd04ee0 into mozilla:master Apr 8, 2026
43 checks passed
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.

[Bug]: Add-on name might be longer than 50 chars

2 participants