ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

using an apostrophe

April 01, 2008 3:25pm

Subscribe [6]
  • #1 / Apr 01, 2008 3:25pm

    socaprice

    217 posts

    Hi all,

    Can someone tell me how to make the EE allow the use of a name with an apostrophe as the username when registering a new member?

    I have a user that has an email that has an apostrophe in it e.g. fred_o’[email protected] - I know underscores are allowed but I did not know apostrophes were allowed in an email address.

    Oh well, you learn something new everyday, is there a way to get the EE to accept that particular email address type as the username and email?

    Thanks,
    Socaprice

  • #2 / Apr 01, 2008 3:42pm

    Mark Bowen

    12637 posts

    Hmm I think that apostrophes as you say are allowed but they aren’t recommended as they may get used incorrectly by certain mail-servers or databases. I think that EE for that reason has them not allowed and this is probably set in the core files I would imagine.

    If that is so then I think you are either looking at a hack (Uggggghhh!!) an extension (maybe if it’s possible to do - not sure on that one) or a feature request to see if this can be added in.

    Hope that helps?

    Best wishes,

    Mark

  • #3 / Apr 01, 2008 3:45pm

    Mark Bowen

    12637 posts

    A little more information on it here :

    http://www.remote.org/jochen/mail/info/chars.html

    Not sure if this is what is happening with EE but one of the dev crew would be able to answer this more efficiently than me though.

    Best wishes,

    Mark

  • #4 / Apr 01, 2008 3:46pm

    socaprice

    217 posts

    Thanks it did. I will try the “hack (Uggggghhh!!)” 😊 first and then cry later.

    Socaprice

  • #5 / Apr 01, 2008 4:12pm

    Mark Bowen

    12637 posts

    So do you know where to go for the hack then?

    Best wishes,

    Mark

  • #6 / Apr 01, 2008 4:15pm

    socaprice

    217 posts

    I believe it would probably be in the cp.members.php and in the core.validate.php correct?

    Unless it is somewhere far far away. Let me know if I am wrong.

    Thanks,
    Socaprice

  • #7 / Apr 01, 2008 4:26pm

    Mark Bowen

    12637 posts

    Well actually I was asking as I thought you already knew from the fact that you had said you were going with the hack 😉

    I guess that’s where it would be though. Perhaps best to ask one of the admin / moderators or dev team on this one though.

    Let me know what you find out won’t you?

    Best wishes,

    Mark

  • #8 / Apr 01, 2008 4:31pm

    socaprice

    217 posts

    I will ask them, however that is where I went to expand the fields so that I could add a username that was longer than 35 characters.

    Any moderators or admins want to jump in????

    Thanks though,
    Socaprice

  • #9 / Apr 01, 2008 5:00pm

    Ingmar

    29245 posts

    I have a user that has an email that has an apostrophe in it e.g. fred_o’[email protected] - I know underscores are allowed but I did not know apostrophes were allowed in an email address.

    RFC2821 actually allows apostrophes in the local part of an email address, but it is nonetheless a very bad idea. I am sure he has a different address, since there are quite a number of systems not accepting such addresses.

    So, technically you are correct, and EE should perhaps accept such addresses. In the meantime, you’ll probably have to modify core.regex.php:

    /** -------------------------------------
    /**  Validate Email Address
    /** -------------------------------------*/
    
    function valid_email($address)
    {
         if ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $address))
                       return false;
               else
                       return true;
    }
    /* END */

    A somewhat oversimpliefied regex, but sufficient for most purposes.

    EDIT: Look at lines 31 following.

  • #10 / Apr 01, 2008 5:56pm

    socaprice

    217 posts

    wow that’s a lot to put in there, not sure where I should put the apostrophe 😊

    I would have to go thru that properly to see how that is filtering the apostrophe, however, would that code apply as well to the username in cp.members.php, cause EE is not allowing the apostrophe in the username either?

    Thanks,
    Socaprice

  • #11 / Apr 01, 2008 6:13pm

    Ingmar

    29245 posts

    wow that’s a lot to put in there, not sure where I should put the apostrophe 😊

    It would depend on where you need them 😊 Do you have any experience with regular expressions? I won’t break them all down to you, but this line

    ^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$

    basically translates to “beginning of string, then at least one of the following characters: a-z, 0-9, + or -, followed by zero or more groups of at least one of the following characters: ., a-z, 0-9, + or -, then an @, followed by at least one group of the following characters: a-z, 0-9, - or ., followed by a final group of 2-6 characters, end of string. I’d insert the apostrophe twice right after the “\-” group.

    I would have to go thru that properly to see how that is filtering the apostrophe

    It’s not filtering apostrophes, it’s only allowing certain characters.

    would that code apply as well to the username in cp.members.php, cause EE is not allowing the apostrophe in the username either?

    That’s a good question, actually. Probably not, would have to check. Derek would know 😊

  • #12 / Apr 01, 2008 6:25pm

    socaprice

    217 posts

    Not much experience with them other than using them for our ISAPIRewrite to remove the index.php?
    Usually I get it once I sit down and study it. I am really good at Google so this co-worker told me about a site, http://regexlib.com/ that people upload regular expressions to and I was able to test my email string there and it worked so I will try using one I found there that allowed me to use the apostrophe and will input that in the core.regex.php file and test, but not now, tomorrow, right now I hear my home calling me. 😊

    Thanks,
    Socaprice

  • #13 / Apr 01, 2008 6:42pm

    Mark Bowen

    12637 posts

    Don’t know if this helps but found this one online :

    ^((\"[^\"\f\n\r\t\v\b]+\")|([\w\!\#\$\%\&\'\*\+\-\~\/\^\`\|\{\}]+(\.[\w\!\#\$\%\&\'\*\+\-\~\/\^\`\|\{\}]+)*))@((\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9\-])+\.)+[A-Za-z\-]+))$

    Email address validator. Should cover most of RFC 822, including unusual (but still valid) addresses.

    I would definitely ask one of the EE dev team about doing all of this first though just to make sure that nothing hooky will happen 😉

    Best wishes,

    Mark

  • #14 / Apr 01, 2008 11:23pm

    Jared Farrish

    575 posts

    A fantastic program for learning and designing Regular Expressions:

    http://www.weitz.de/regex-coach/

    Awesome! :coolhmm:

    Ask him if he can set up an alias that can be referenced to his (probably invalid) email address, something like:

    .(JavaScript must be enabled to view this email address)

    With aliases, he can setup the above (on his domain) and then have those emails either routed to his other (primary) email address, or vice versa.

    Also, he could setup a forwarder on something like GMail and you could use that.

    But I would be wary of email addresses with apostrophe’s in them. Not good.

  • #15 / Apr 02, 2008 1:19am

    Dan Lovejoy

    115 posts

    The apostrophe in a name is an identity issue - (I’ve only seen it in Irish names) but one good example of how we sometimes compromise human needs to accommodate technology. Many people of Irish descent resent having to remove the apostrophe so setting up public aliases would defeat the purpose of “making a stand” on such an issue. I guess someone has to make a stink, or standards won’t change and programmers won’t accommodate folks with names that don’t fit into an easier model. I’m just glad I’m not the one making the stand. 😊 Having said that, I sympathize with programmers who have to deal with apostrophes- especially in the context of HTML/Javascript where it can cause all kinds of havoc.

    Ironically, the apostrophe is a vestige of British rule and wasn’t present in Irish names before the English added it.

    http://www.cnn.com/2008/TECH/ptech/02/21/apostrophe.trouble.ap/

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases