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

Hotfix: Accept ASCII_8BIT encoded strings as valid values on serialize #51

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/mysql-binuuid/type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ def cast(value)
# it to the database.
def serialize(value)
return if value.nil?
undashed_uuid = strip_dashes(value)
if value.is_a?(String) && value.encoding == Encoding::ASCII_8BIT && strip_dashes(value).length != 32
undashed_uuid = value.unpack1('H*')
else
undashed_uuid = strip_dashes(value)
end

# To avoid SQL injection, verify that it looks like a UUID. ActiveRecord
# does not explicity escape the Binary data type. escaping is implicit as
Expand Down