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

Fix I18n.interpolate when ActiveSupport::SafeBuffer passed as argument #216

Merged
merged 1 commit into from
Nov 20, 2016
Merged

Fix I18n.interpolate when ActiveSupport::SafeBuffer passed as argument #216

merged 1 commit into from
Nov 20, 2016

Conversation

bogdan
Copy link
Contributor

@bogdan bogdan commented Aug 31, 2013

There could be a problem with ActiveSupport::SafeBuffer and I18n interpolate.
I've implemented a part of SafeBuffer that cause the issue in the test case.

I18n.interpolate("%{a}".html_safe, :a => 1)

By some reason $1 and $2 is not set appropriately and we have to use gsub match data instead.

@radar
Copy link
Collaborator

radar commented Nov 2, 2016

What is the use case of passing a safe buffer here? Would anyone realistically use this in their code?

@bogdan
Copy link
Contributor Author

bogdan commented Nov 2, 2016

@radar I did. The thing is - you never know if buffer you are using is safe or not.

The example of that would be:

<%= I18n.interpolate("Get your &euro;%{amount} off".html_safe, amount: 10) %>

In my case, users are editing localizations themselves and basic HTML is allowed (like in markdown).

@radar
Copy link
Collaborator

radar commented Nov 20, 2016

Ok, that makes sense to me. Thanks @bogdan.

@radar radar merged commit e532e61 into ruby-i18n:master Nov 20, 2016
@radar radar added this to the 0.8.0 milestone Nov 20, 2016
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