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

Sanitize organization name #20393

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

laicuRoot
Copy link

@laicuRoot laicuRoot commented Nov 24, 2023

Description

In this pull request, I addressed an issue related to the HTML rendering of organization names in the application. The problem manifested when special characters, such as '&' in the organization name, were not properly escaped, leading to unintended rendering in the UI.

To resolve this issue, I utilized the built-in sanitize method provided by Rails. This ensures that organization names are properly sanitized before being rendered in HTML.

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Related Tickets & Documents

QA Instructions, Screenshots, Recordings

Please replace this line with instructions on how to test your changes, a note
on the devices and browsers this has been tested on, as well as any relevant
images for UI changes.

UI accessibility checklist

If your PR includes UI changes, please utilize this checklist:

  • Semantic HTML implemented?
  • Keyboard operability supported?
  • Checked with axe DevTools and addressed Critical and Serious issues?
  • Color contrast tested?

For more info, check out the
Forem Accessibility Docs.

Added/updated tests?

We encourage you to keep the code coverage percentage at 80% and above.

  • Yes
  • No, and this is why: please replace this line with details on why tests
    have not been included
  • I need help with writing tests

[optional] Are there any post deployment tasks we need to perform?

[optional] What gif best describes this PR or how it makes you feel?

alt_text

Copy link
Contributor

Thank you for opening this PR! We appreciate you!

For all pull requests coming from third-party forks we will need to
review the PR before we can process it through our CI pipelines.

A Forem Team member will review this contribution and get back to
you as soon as possible!

Copy link
Contributor

github-actions bot commented Nov 24, 2023

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@laicuRoot
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

Closes issue 20376

In this pull request, I addressed an issue related to the HTML rendering
of organization names in the application. The problem manifested when
special characters, such as '&' in the organization name, were not being
properly escaped, leading to unintended rendering in the UI.

To resolve this issue, I utilized the built-in `sanitize` method
provided by Rails. This ensures that organization names are
properly sanitized before being rendered in HTML.
@laicuRoot laicuRoot force-pushed the laicuroot/sanitize-user-name-20376 branch from 9ec6bff to 79af2b3 Compare November 24, 2023 14:45
@laicuRoot laicuRoot marked this pull request as ready for review November 24, 2023 14:46
@laicuRoot laicuRoot requested a review from a team as a code owner November 24, 2023 14:46
@laicuRoot laicuRoot requested review from lightalloy and maestromac and removed request for a team November 24, 2023 14:46
@dambar08
Copy link
Contributor

Prefer to use

class OrganizationDecorator

def sanitized_name
sanitize(name)
end

Copy link
Contributor

@maestromac maestromac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for the delay. I have to agree with @dambar08 here. The more clean approach here would be to to utilize OrganizationDecorator instead of manually sanitizing names in multiple places. Let me know if you need any more guideline.

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.

The & character in organization's names is not displayed correctly:
3 participants