Skip to content

Escape custom keys in reserved interpolation regexp - #744

Closed
OskarEichler wants to merge 1 commit into
ruby-i18n:masterfrom
OskarEichler:codex/reserved-key-regexp
Closed

Escape custom keys in reserved interpolation regexp#744
OskarEichler wants to merge 1 commit into
ruby-i18n:masterfrom
OskarEichler:codex/reserved-key-regexp

Conversation

@OskarEichler

Copy link
Copy Markdown

Summary

Escape each reserved interpolation key before composing the cached regular expression.

Custom keys registered with I18n.reserve_key are arbitrary symbols. Treating regex metacharacters in those names as syntax can make unrelated placeholders look reserved.

Verification

  • focused external regression model for metacharacter-bearing reserved keys
  • 1,607 base-suite runs / 2,674 assertions
  • 1,888 Rails-suite runs / 3,020 assertions
  • all 46 shipped Ruby files pass syntax checks

@fz-ryanbigg

Copy link
Copy Markdown

But why?

@OskarEichler

Copy link
Copy Markdown
Author

This came from the broad dependency audit rather than a concrete application failure. Regex metacharacters are technically accepted by reserve_key and can alter matching, but I do not have a real-world reserved key that triggers this. I am closing the speculative change.

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.

2 participants