Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only allow proper identifiers as strings keys #615

Conversation

kurthuwig
Copy link

The old code checked if key and text are identical, which made no sense as there is no such limitation. On the other hand it allowed keys like "test-key" which are invalid on Android.

The new code checks if the identifier starts with an ASCII letter or underscore and only contains ASCII lettes, digits or underscores.

@Alex009
Copy link
Member

Alex009 commented Dec 18, 2023

EqualStringKeysException make sense - on string equality works logic on iOS for case when in specific language not exist some value - will be used from base locale.

for additional checks of keys - thanks :)

@Alex009 Alex009 added this to the 0.24.0 milestone Dec 18, 2023
@kurthuwig
Copy link
Author

EqualStringKeysException make sense - on string equality works logic on iOS for case when in specific language not exist some value - will be used from base locale.

for additional checks of keys - thanks :)

I am confused: my understanding is that if the key does not exist in a language, then the base's entry is for this key is used.
Except for GNU's gettext I have not seen using the value for looking up translations for a long time. AFAIK even on iOS keys are used to look up values in specific languages.

Can you please pinpoint me to any documentation or code that uses the values associated with the keys to look up things in other maps?

The old code checked if key and text are identical, which made no sense
as there is no such limitation. On the other hand it allowed keys like
"test-key" which are invalid on Android.

The new code checks if the identifier starts with an ASCII letter or
underscore and only contains ASCII lettes, digits or underscores.
@kurthuwig kurthuwig force-pushed the feature/verify-string-identifiers-characters branch from a0b3492 to 5f7fd02 Compare December 18, 2023 10:24
ExNDY added a commit that referenced this pull request Apr 17, 2024
@ExNDY
Copy link
Contributor

ExNDY commented Apr 17, 2024

Thank you for idea, we reuse your check logic of key validation for actual generation mechanic.
will be implemented in 0.24.0-alpha-6

@Alex009
Copy link
Member

Alex009 commented Apr 18, 2024

this change was done in #575

@Alex009 Alex009 closed this Apr 18, 2024
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.

3 participants