Prevent vue-i18n special characters causing error #11287
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #11056
Context
Ref #11056 (comment). There are several special characters in vue-i18n that will cause error when users add them in field/collection translations.
For example, if a user types
title@here
as the field translation, the@
will be interpreted as linked message. But since the format is malformed (it should be@:key
wherekey
is an existing translation key), it errors out.The offending line is here inside
parseField
function:directus/app/src/stores/fields.ts
Line 90 in 3a905b1
This will only throw console errors during dev, but it ends up throwing an error in production environment and prevent any logged in user in that particular locale from doing anything.
Solution
Apply the recommended literal interpolations on all the special characters when they are parsed.
Result