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 joins not to make strings unsafe #704

Merged
merged 2 commits into from
Sep 26, 2023

Conversation

lcreid
Copy link
Contributor

@lcreid lcreid commented Sep 22, 2023

The basic String#join makes its output unsafe in all cases. This might have been causing unwanted and problematic escaping in some cases. This PR removes the use of String#join. It should still escape unsafe strings passed in from the calling code, while not escaping anything that is already safe. However, that's something reviewers should put some thoughts into, and comment on.

This PR may cause some text to be escaped that wasn't previously escaped, but those cases would have been potentially security vulnerabilities, so I think it's justifiable in closing that possible loophole. The fix would be for the calling code to pass its string as string.html_safe if the code is confident the string is safe (i.e. it doesn't come from the user or the database or something external). If the string wasn't safe, then it should get escaped.

@lcreid lcreid self-assigned this Sep 23, 2023
@lcreid lcreid requested a review from donv September 23, 2023 02:10
Copy link
Contributor

@UweKubosch UweKubosch left a comment

Choose a reason for hiding this comment

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

Looks good to me 😄

@@ -81,7 +81,8 @@ def get_error_messages(name)
end
end

object.errors[name].join(", ")
safe_join(object.errors[name], ", ")
# object.errors[name].join(", ")
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove commented code.

@lcreid lcreid merged commit 95596b0 into bootstrap-ruby:main Sep 26, 2023
11 checks passed
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