CC: | mark [...] repixl.com |
Subject: | Unicode string causes error |
Hi there,
If we use DBIx::Class with enable_utf8 then the strings we use in our RS
will be perl internal strings. Bcrypt expects an octet sequence, though,
and blows up on trying to encode the perl sequence with "input must
contain only octets".
I figure the solution is just to utf8::encode what's flagged as utf8.
Patch below.
Regards
Gareth
---
perl/lib/site_perl/5.14.1/DBIx/Class/EncodedColumn/Crypt/Eksblowfish/Bcr
ypt.pm 2011-04-11 19:51:04.000000000 +0000
+++ lib/DBIx/Class/EncodedColumn/Crypt/Eksblowfish/Bcrypt.pm 2012-06-
28 11:09:51.000000000 +0000
@@ -24,6 +24,11 @@
my $encoder = sub {
my ($plain_text, $settings_str) = @_;
+ if (utf8::is_utf8($plain_text)){
+ # Bcrypt expects octets. This dbi is probably going to encode
later
+ # so we'll have to do this now
+ utf8::encode($plain_text);
+ }
unless ( $settings_str ) {
my $salt = join('', map { chr(int(rand(256))) } 1 .. 16);
$salt = Crypt::Eksblowfish::Bcrypt::en_base64( $salt );