Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@rodrigoargumedo
Copy link
Contributor

I was in the middle of doing a Rails project and overriding the default template. I did some ERB linting and the suite told me the following message:

erb interpolation with '<%= (...).html_safe %>' in this context is never safe
In file: app/views/kaminari/_first_page.html.erb:10

My original expectation for this request was to be sanitized, but it isn't. I ended up by fixing the view code to use the sanitize(...) method to prevent potential XSS attacks. It allows the method to properly read the characters in a sanitized context.

Let me know if you have any questions for me.

@yuki24
Copy link
Member

yuki24 commented Aug 8, 2024

I was not sure if it makes sense to sanitize translations, as they are not user inputs. It may actually break the HTML, as they are supposed not to be sanitized. Rather than calling sanitize everywhere, is there any way we could introduce _html-suffixed translations, as documented here? This could be a breaking change though.

@rodrigoargumedo
Copy link
Contributor Author

I was not sure if it makes sense to sanitize translations, as they are not user inputs. It may actually break the HTML, as they are supposed not to be sanitized. Rather than calling sanitize everywhere, is there any way we could introduce _html-suffixed translations, as documented here? This could be a breaking change though.

@yuki24 I think that is also doable and will make changes accordingly to that.

@rodrigoargumedo rodrigoargumedo marked this pull request as draft August 8, 2024 12:25
@rodrigoargumedo rodrigoargumedo marked this pull request as ready for review August 8, 2024 13:09
@rodrigoargumedo
Copy link
Contributor Author

Ready for review again.

@rodrigoargumedo rodrigoargumedo changed the title Sanitize i18n inputs on pagination links Add Safe HTML i18n translations Aug 8, 2024
@rodrigoargumedo rodrigoargumedo changed the title Add Safe HTML i18n translations Add Safe HTML i18n Translations Aug 8, 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.

2 participants