-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Closed as not planned
Labels
[Package] i18n/packages/i18n/packages/i18n[Type] BugAn existing feature does not function as intendedAn existing feature does not function as intended
Description
Description
#70434 switched the underlying library used for sprintf to use @tannin/sprintf instead of sprintf-js. While the stronger typing is a good improvement, the change is breaking for any usage of sprintf in the wild which passes in undefined as the format string (example).
To be explicit (quoting @aduth from this comment):
- ✅
sprintf('Hello, %(name)s', { name: undefined })➡️'Hello, '- ✅
sprintf('Hello, %(name)s', undefined)➡️'Hello, '- ❌
sprintf(undefined);➡️Uncaught TypeError: Cannot read properties of undefined (reading 'replace')
Might not be an overly common case, given it would likely only surface when a variable is passed into sprintf for the format string (and that variable might be undefined).
sprintf-jsimplicitly handledundefined: https://github.com/alexei/sprintf.js/blob/3a0d8c26d291b5bd9f1974877ecc50739921d6f5/src/sprintf.js#L150@tannin/sprintfdoes not: https://github.com/aduth/tannin/blob/630d3e3a00345005d1c06353779ce770ff22719f/packages/sprintf/src/index.js#L115
Please confirm that you have searched existing issues in the repo.
- Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
- Yes
Metadata
Metadata
Assignees
Labels
[Package] i18n/packages/i18n/packages/i18n[Type] BugAn existing feature does not function as intendedAn existing feature does not function as intended