-
Notifications
You must be signed in to change notification settings - Fork 15
Fix escape characters in categories #891
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
base: develop
Are you sure you want to change the base?
Conversation
alecslupu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Stef-Rousset head's up!
|
|
||
| categories_values = sorted_main_categories.flat_map do |category| | ||
| sorted_descendant_categories = category.descendants.includes(:subcategories).sort_by do |subcategory| | ||
| [subcategory.weight, translated_attribute(subcategory.name)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use here a "decidim_sanitize_translated", to avoid XSS ?
| [subcategory.weight, translated_attribute(subcategory.name)] | |
| [subcategory.weight, decidim_sanitize_translated(subcategory.name)] |
| end | ||
|
|
||
| subcategories = sorted_descendant_categories.flat_map do |subcategory| | ||
| Decidim::CheckBoxesTreeHelper::TreePoint.new(subcategory.id.to_s, translated_attribute(subcategory.name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not a ?
| Decidim::CheckBoxesTreeHelper::TreePoint.new(subcategory.id.to_s, translated_attribute(subcategory.name)) | |
| Decidim::CheckBoxesTreeHelper::TreePoint.new(subcategory.id.to_s, decidim_sanitize_translated(subcategory.name)) |
| end | ||
|
|
||
| Decidim::CheckBoxesTreeHelper::TreeNode.new( | ||
| Decidim::CheckBoxesTreeHelper::TreePoint.new(category.id.to_s, translated_attribute(category.name)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Decidim::CheckBoxesTreeHelper::TreePoint.new(category.id.to_s, translated_attribute(category.name)), | |
| Decidim::CheckBoxesTreeHelper::TreePoint.new(category.id.to_s, decidim_sanitize_translated(category.name)), |
|
Hello @alecslupu , thanks for your review ! I totally understand your concern about the security. I have a little question about this case, and I will appreciate your expertise on it. I tested (in the decidim-app) the categories without escape in front, and the Also, the scopes, which are as categories created in the BO, are not sanitized in the BO nor in the FO, and the script I would really appreciate your analysis on this topic, thanks and have a nice day ! |


🎩 Description
This PR removes escaping from categorie's names in FO.
Testing
As an admin, go to a process > Categories and update the name of a category, adding special characters (like '&"<>).
As a user, go to the proposals of the process and see that the category's name you have updated is displayed with its special characters not escaped.
📌 Related Issues
Link your PR to an issue
Tasks
📷 Screenshots
BO

FO
