-
Notifications
You must be signed in to change notification settings - Fork 68
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
Correctly handle a frozen string with invalid characters #73
Conversation
@@ -109,11 +109,12 @@ def truncate_string(str) | |||
# @return [void] | |||
# @note This method mutates +str+ for speed |
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.
Could you delete this line and update the line above?
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.
Sure. Also, would you prefer keeping the bang in the method name since it still modifies the argument when it's not frozen?
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.
Good call, it makes sense. I guess it's also better to update this note, to mention that it mutates every but frozen strings.
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.
done
cf6c3aa
to
39c1234
Compare
# @note This method mutates +str+ for speed | ||
# @return [String] a UTF-8 encoded string | ||
# @note This method mutates +str+ unless it's frozen, | ||
# in which case it creates a duplicate |
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.
According to YARD (the notation we use to generate docs), we should be using two spaces here:
# @note This method mutates +str+ unless it's frozen,
# in which case it creates a duplicate
Massive thanks for the PR, @bobes, great find & PR! |
39c1234
to
9184b7d
Compare
thanks for the feedback, I hope it's alright now :) I would appreciate if you could bump the version and push it to rubygems, thank you. |
Sure, expect a release today. :) |
Just released |
This change fixes a
RuntimeError: can't modify frozen String
error that happens in Payload Truncator when a string with invalid characters is frozen