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

Correctly handle a frozen string with invalid characters #73

Merged
merged 1 commit into from
May 4, 2016

Conversation

bobes
Copy link
Contributor

@bobes bobes commented May 4, 2016

This change fixes a RuntimeError: can't modify frozen String error that happens in Payload Truncator when a string with invalid characters is frozen

@@ -109,11 +109,12 @@ def truncate_string(str)
# @return [void]
# @note This method mutates +str+ for speed
Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@bobes bobes force-pushed the fix_frozen_string_bug branch from cf6c3aa to 39c1234 Compare May 4, 2016 10:08
# @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
Copy link
Contributor

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

@kyrylo
Copy link
Contributor

kyrylo commented May 4, 2016

Massive thanks for the PR, @bobes, great find & PR!
If you could fix the nitpick (#73 (comment)) and squash all your commits into one, then this is ready to be merged.

@bobes bobes force-pushed the fix_frozen_string_bug branch from 39c1234 to 9184b7d Compare May 4, 2016 12:19
@bobes
Copy link
Contributor Author

bobes commented May 4, 2016

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.

@kyrylo kyrylo merged commit 1ef3a59 into airbrake:master May 4, 2016
kyrylo added a commit that referenced this pull request May 4, 2016
@kyrylo
Copy link
Contributor

kyrylo commented May 4, 2016

Sure, expect a release today. :)

@kyrylo
Copy link
Contributor

kyrylo commented May 4, 2016

Just released airbrake-ruby-1.2.4. Happy Airbraking!

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