Thursday, June 21, 2012

Weird string encoding issue with ruby net-ldap lib ( 0.3.1 )


Getting this error:

#

The fix was to enable some invalid encoding checks, so here is the original line ( ~23 net-ldap-0.3.1/lib/net/ber/core_ext/string.rb ):

self.encode('UTF-8').force_encoding('ASCII-8BIT')

After some playing around I found that this works rather well:

self.encode('UTF-8', invalid: :replace, undef: :replace, replace: '' ).force_encoding('ASCII-8BIT')

I couldn't find the git source for the 0.3.1 build, so I just downloaded the gem, and created a new repo.

You can download the gem from here:
https://docs.google.com/open?id=0Bwcyw39lMxDSODdpNTdObHk4bXc

I'm going to try to see if I can get this pushed upstream.