#809 ✓resolved
ash.gti

Ruby 1.9 dm-validations email validator

Reported by ash.gti | March 2nd, 2009 @ 12:39 AM

Whenever you include dm-validations in ruby 1.9 you get:

require 'dm-validations' ArgumentError: invalid multibyte escape

(plus some line numbers and a backtrace).

This is because in the new Regex engine they have a strict encoding check that validates the regex is using only valid characters. Specifically, in the regex there is: http://github.com/datamapper/dm-... which checks for invalid characters isn't legal (even though its doing the regex not ([^]) its not legal for a regex in ruby 1.9 to contain those characters.

You can check if a string contains those illegal characters by calling its encoding, ("Some string".encode "US-ASCII" will attempt to check the encoding, or you can force_encoding or try "hello".ascii_only?)

I am not sure exactly what the best solution is to this... To conform with the RFC2822 standard the current regex uses emails really should only contain valid ASCII characters, so I guess you could turn this into a function instead of a regex to validate the email address, or modify the regex and just ignore the invalid character checks... I just wanted to bring this up so we can find the best solution to this problem.

Comments and changes to this ticket

  • ash.gti

    ash.gti March 6th, 2009 @ 02:29 PM

    this isn't really valid anymore, I talked to dkubb in IRC and the encoding was wrong in the version of dm-validations I was using. It just needs to be set to encoding: binary for anyone that is curious. Its already been committed and should be in the next release of dm-validations.

    tl;dr; this isn't any issue anymore.

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) May 28th, 2009 @ 07:15 PM

    • State changed from “unconfirmed” to “resolved”
    • Assigned user set to “Dan Kubb (dkubb)”

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

People watching this ticket

Pages