FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Make version attribute a plain String by mattwildig · Pull Request #107 · bcrypt-ruby/bcrypt-ruby · GitHub

Repository navigation

Make version attribute a plain String - #107

Merged
tjschuck merged 1 commit into
bcrypt-ruby:masterfrom
mattwildig:version-attribute-string
Jan 29, 2015
Merged

tjschuck merged 1 commit into
bcrypt-ruby:masterfrom
mattwildig:version-attribute-string

Conversation

Copy link
Copy Markdown
Contributor

This is a fix for #106. It looks fairly simple so I thought I’d do a quick PR.

When splitting the hash into the components to populate the attributes in Password the salt and hash were being converted into plain strings with to_str, but the version wasn’t. This was causing problems when trying to use == on that attribute (a change to Psych to how strings are serialized to Yaml does this).

This fix just adds a call to to_str to the version, to match the salt and hash (the cost is converted with to_i) and adds a matching spec.


As an aside: This fixes the immediate issue. Dumping a Password to Yaml now looks something like this:

--- !ruby/string:BCrypt::Password
str: "$2a$10$xbRosG0W6.XkTBSWYDTaVeFTNtWa3uHwudnwLme.KAKkVYMSalqLW"
version: 2a
cost: 10
salt: "$2a$10$xbRosG0W6.XkTBSWYDTaVe"
checksum: FTNtWa3uHwudnwLme.KAKkVYMSalqLW

which is what it looked like in Ruby 2.1 (or more accurately with the version of Psych in Ruby 2.1). The version, cost, salt and checksum are all duplicated. Is it worth adding init_with and encode_with methods to avoid this repetition?

tmm1 commented Jan 28, 2015

Copy link
Copy Markdown
Collaborator

This looks reasonable. WDYT @tjschuck ?

Copy link
Copy Markdown
Collaborator

Yep, this looks good to me.

Sorry for the delay, @mattwildig, and thanks! ❤️ ❤️ 😻 ❤️

tjschuck added a commit that referenced this pull request Jan 29, 2015
tjschuck merged commit 3aa15b6 into bcrypt-ruby:master Jan 29, 2015

Copy link
Copy Markdown
Collaborator

(Building and publishing a new version of the gem shortly -- stay tuned for that.)

Copy link
Copy Markdown
Collaborator

@mattwildig @tmm1 Version 3.1.10 has been pushed to RubyGems.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

3 participants


Back | FazBrowse Home | New Git URL