How not to validate an email address (Or a GUID) (Or a number)




  • Stumbled across these three methods in a ~10K LOC God-Object.

    private static Regex regGuid = new Regex(@"^(\{){0,1}[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}(\}){0,1}$", RegexOptions.Compiled);
    
        <span style='color:#800000; font-weight:bold; '>internal</span> <span style='color:#800000; font-weight:bold; '>static</span> <span style='color:#800000; font-weight:bold; '>bool</span> IsGuid<span style='color:#808030; '>(</span><span style='color:#800000; font-weight:bold; '>string</span> candidate<span style='color:#808030; '>)</span>
        <span style='color:#800080; '>{</span>
            <span style='color:#800000; font-weight:bold; '>bool</span> isValid <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>false</span><span style='color:#800080; '>;</span>
    
            <span style='color:#800000; font-weight:bold; '>if</span> <span style='color:#808030; '>(</span>candidate <span style='color:#808030; '>!</span><span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>null</span><span style='color:#808030; '>)</span>
            <span style='color:#800080; '>{</span>
    
                <span style='color:#800000; font-weight:bold; '>if</span> <span style='color:#808030; '>(</span>regGuid<span style='color:#808030; '>.</span>IsMatch<span style='color:#808030; '>(</span>candidate<span style='color:#808030; '>)</span><span style='color:#808030; '>)</span>
                <span style='color:#800080; '>{</span>
                    isValid <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>true</span><span style='color:#800080; '>;</span>
                <span style='color:#800080; '>}</span>
            <span style='color:#800080; '>}</span>
    
            <span style='color:#800000; font-weight:bold; '>return</span> isValid<span style='color:#800080; '>;</span>
        <span style='color:#800080; '>}</span>
    
        <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#800000; font-weight:bold; '>static</span> Regex isEmail <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> Regex<span style='color:#808030; '>(</span>@<span style='color:#800000; '>"</span><span style='color:#0000e6; '>^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$</span><span style='color:#800000; '>"</span><span style='color:#808030; '>,</span> RegexOptions<span style='color:#808030; '>.</span>Compiled<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
    
        <span style='color:#800000; font-weight:bold; '>internal</span> <span style='color:#800000; font-weight:bold; '>static</span> <span style='color:#800000; font-weight:bold; '>bool</span> IsEmail<span style='color:#808030; '>(</span><span style='color:#800000; font-weight:bold; '>string</span> strEmail<span style='color:#808030; '>)</span>
        <span style='color:#800080; '>{</span>
            <span style='color:#800000; font-weight:bold; '>bool</span> isValid <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>false</span><span style='color:#800080; '>;</span>
            <span style='color:#800000; font-weight:bold; '>if</span> <span style='color:#808030; '>(</span>strEmail <span style='color:#808030; '>!</span><span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>null</span><span style='color:#808030; '>)</span>
            <span style='color:#800080; '>{</span>
                <span style='color:#800000; font-weight:bold; '>if</span> <span style='color:#808030; '>(</span>isEmail<span style='color:#808030; '>.</span>IsMatch<span style='color:#808030; '>(</span>strEmail<span style='color:#808030; '>)</span><span style='color:#808030; '>)</span>
                <span style='color:#800080; '>{</span>
                    <span style='color:#696969; '>//output = new Guid(candidate);</span>
                    isValid <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>true</span><span style='color:#800080; '>;</span>
                <span style='color:#800080; '>}</span>
            <span style='color:#800080; '>}</span>
    
            <span style='color:#800000; font-weight:bold; '>return</span> isValid<span style='color:#800080; '>;</span>
        <span style='color:#800080; '>}</span>
    
        <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#800000; font-weight:bold; '>static</span> Regex isNumber <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> Regex<span style='color:#808030; '>(</span>@<span style='color:#800000; '>"</span><span style='color:#0000e6; '>^[0-9]+$</span><span style='color:#800000; '>"</span><span style='color:#808030; '>,</span> RegexOptions<span style='color:#808030; '>.</span>Compiled<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
    
        <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#800000; font-weight:bold; '>static</span> <span style='color:#800000; font-weight:bold; '>bool</span> IsNumber<span style='color:#808030; '>(</span><span style='color:#800000; font-weight:bold; '>string</span> strNumber<span style='color:#808030; '>)</span>
        <span style='color:#800080; '>{</span>
            <span style='color:#800000; font-weight:bold; '>bool</span> isValid <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>false</span><span style='color:#800080; '>;</span>
            <span style='color:#800000; font-weight:bold; '>if</span> <span style='color:#808030; '>(</span>strNumber <span style='color:#808030; '>!</span><span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>null</span><span style='color:#808030; '>)</span>
            <span style='color:#800080; '>{</span>
                <span style='color:#800000; font-weight:bold; '>if</span> <span style='color:#808030; '>(</span>isNumber<span style='color:#808030; '>.</span>IsMatch<span style='color:#808030; '>(</span>strNumber<span style='color:#808030; '>)</span><span style='color:#808030; '>)</span>
                <span style='color:#800080; '>{</span>
                    isValid <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>true</span><span style='color:#800080; '>;</span>
                <span style='color:#800080; '>}</span>
            <span style='color:#800080; '>}</span>
    
            <span style='color:#800000; font-weight:bold; '>return</span> isValid<span style='color:#800080; '>;</span>
        <span style='color:#800080; '>}</span>
    

    I had planned to write a nice little story about the discovery and an explicit explanation about how stupid these are and point out the much simpler ways of doing this in .Net, but the more I thought about it the more depressed I got. So I'll just share it with you, instead, and get drunk later.


  • Winner of the 2016 Presidential Election

    @mikeTheLiar said:

    {0,1}

    I see the WTF. They waste like 4 characters by typing that instead of ?.



  • The real question is: did you not want to repeat things after telling the coworker that checked that in, or did you just not want to explain?  While the second is understandable it also means you are going to find more like this.



  • @locallunatic said:

    The real question is: did you not want to repeat things after telling the coworker that checked that in, or did you just not want to explain?  While the second is understandable it also means you are going to find more like this.


    This pre-dates me (the "it was like that when I got here" defence). Said co-worker is now gone, leaving just myself.



  • @mikeTheLiar said:

    a ~10K LOC God-Object

    The best of the best of the objects.



  • So I commented the whole block out:

    [code]
    
            /*
             * WHAT THE SHITTING DICK-NIPPLES IS THIS?!?!?!?
             * Jesus titty-fucking Christ, how goddam stupid can people get?
             * Oh god. It's happening.
             * I'm turning into blakeyrat.
             * I'm leaving this here as evidence.
             * If I go crazy and climb up a clock tower
             * and start taking bastards out, this is why.
            
            private static Regex regGuid = new Regex(@"^(\{){0,1}[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}(\}){0,1}$", RegexOptions.Compiled);
            [...snip...]
    [/code]
    

    Even better, the compiler only complained a little. [code]IsGuid[/code] was only called twice, [code]IsNum[/code] once, and [code]isEmail[/code] was called exactly never. Which is probably for the best, I just re-wrote those to use [code]TryParse[/code] like a normal human being, and I don't have to fuck around trying to validate email addresses.

    Actually, that would have been easy. [code]bool IsEmail(string goFuckYourselfAssholeWhoWroteThisMethod) { return true; }[/code]



  • FUCK FUCK FUCK FUCK FUCK. I wasn't thorough enough and and a full clean and rebuild found enough other references that I have to keep the method signatures. GODDAMIT. INCLUDING THE FUCKING ISEMAIL.



  •  If you have to validate Type 1 Guids - rarely used any more, although they are truly the only "globally unique" type....Neither TryParse nor the RegEx is actually a "valid" test....



  • @mikeTheLiar said:

    private static Regex isNumber = new Regex(@"^[0-9]+$", RegexOptions.Compiled);

    I don't see the problem with this one. They're simply implementing base-10 octal.



  • @mikeTheLiar said:

    a full clean and rebuild found enough other references that I have to keep the method signatures.

    So TRWTF is that your build system doesn't accurately track dependencies?




  • @Ben L. said:

    I don't see the problem with this one. They're simply implementing base-10 octal.

    Somewhere in a JS file we have this code:

    $('input[type="number"]').each(function(){
        $(this).attr("pattern","\\d*");
        this.type="text";
    });

    Because who needs fractions, right? It's not like we're trying to run a bank or anything (we are).



  • @Faxmachinen said:

    Because who needs fractions, right? It's not like we're trying to run a bank or anything (we are).
     

    You (and the OP) also don't need negative numbers. And explicitly marking a number as positive (by putting a + sign before it) is something nobody ever does.



  • @DaveK said:

    @mikeTheLiar said:

    a full clean and rebuild found enough other references that I have to keep the method signatures.

    So TRWTF is that your build system doesn't accurately track dependencies?


    No, that was actually me being very, very stupid. I actually considered not posting at all considering how stupid it was. Basically I assumed that there were no calls outside of said God Object. Turns out there were a bunch.



  • @mikeTheLiar said:

    I have to keep the method signatures. GODDAMIT. INCLUDING THE FUCKING ISEMAIL.
    Well of course. Haven't you reaed Moby Dick? The very first sentence is "Call me Isemail"



  • @mikeTheLiar said:

    @locallunatic said:

    The real question is: did you not want to repeat things after telling the coworker that checked that in, or did you just not want to explain?  While the second is understandable it also means you are going to find more like this.


    This pre-dates me (the "it was like that when I got here" defence). Said co-worker is now gone, leaving just myself.

    It's very entertaining to hate long gone people. Someone named "Ken" used to work for one of my clients, my only knowledge of him is from source code comments and check-ins, and I will hate that dude forever. Actually his name is now a common insult in the IT group ("don't go Ken on me", etc) and he is informally known as Ken't.

    My favorite thing about Ken is that he coded an utility that does some unknown black magic and vomits a password-protected file which must be manually unlocked by someone to load new resources in the CRM database. As far as I can tell the source code for that utility was never checked-in and with an 11-week backlog of higher-priority tasks, for the foreseeable future it will remain unchanged. Which means that until further notice there is a lady in sales that needs to type "lolcunt" everyday to unlock the data she needs. Like me she never meant Ken but she hates him.

    to Ken and all Ken-like individuals: wherever you are, fuck you.



  • @Ronald said:

    Which means that until further notice there is a lady in sales that needs to type "lolcunt" everyday to unlock the data she needs.
     

    sudden snort



  • @mikeTheLiar said:

    Actually, that would have been easy. <font face="Lucida Console" size="2">bool IsEmail(string goFuckYourselfAssholeWhoWroteThisMethod) { return true; }</font>
     

    The project I'm currently working on in my workplace uses a mail validator that requires an at symbol, and at least one character at each side of it.

    Yes, that'll fail to validate some valid emails, but none of them are valid at the context of this (or nearly any)  project. Yes, it has value - not letting the user enter the data of on the wrong field is an obvious gain; there are other less obvious ones.



  • Finally one of mike's post annoys me enough to post.  Why do you take offense to regex for these cases?

    isGUID: Tests for a valid guid format, a .net built-in function isn't around till .net4 according to a quick google, that's only 3 years ago.

    isEmail: Verifies it at least looks like a valid email address, what, would you honestly do a try{sendEmail();} catch{SMTPHost email could not be sent} instead? I don't see a built-in alternate but I'm not from the .net world.

    isNumber: well, maybe I can see writing this as a parseInt catch.

    -----------------------------------------

    And of course, there's still the coding style war over try/catch vs. avoid.  I'm on the avoid side of the fence.

    (Disclaimer, I use regex with some frequency, and some parts of the code are stable enough that I can even write some of the requisite boiler-plate code using regex: "$1$2$3$4$5$6$7 $3 $5:$2>" was the replace expression of a find/replace operation I was doing at the time.)



  • @DKATyler said:

    isEmail: Verifies it at least looks like a valid email address
    Except it doesn't. It'll reject foo+bar@gmail.com (a valid e-mail address) and accept .foo.@bar.com, whatever@11.22.33.44 and bar@quux (which are all invalid).



  • @DKATyler said:

    Finally one of mike's post annoys me enough to post.

    I am the worst of the worst, after all.
    @DKATyler said:
    Why do you take offense to regex for these cases?

    It's entirely unnecessary. If you ever find yourself writing a regex to validate whether something is a number or not, stop. You have a hammer. Not everything is a nail. The GUID thing I'll give you, it's entirely possible this code was written more than three years ago. As far as email addresses go, I'm firmly in the "do not try to validate email addresses, even without regex" camp. In the same vein as names, for which I also just provide a single text box - no first/last middle initial bullshit, and don't try to validate beyond making it required, and even then only when absolutely neccessary. If I'm asking for an email, that's because I want to send you something - if you don't want to get it, that's on you, and I'm not going to try and force you.

    Also, there's a bunch of other things in this sample that I hate as well, they're just overshadowed by the larger WTFs.



  • @ender said:

    bar@quux

    Technically you are allowed to do that format, it's just that most TLDs don't accept emails (or it could be the name of a host you are sending to).



  • @locallunatic said:

    Technically you are allowed to do that format, it's just that most TLDs don't accept emails (or it could be the name of a host you are sending to).
    Even for TLDs that have MX record, the e-mail probably won't reach them, because if there's no . in the hostname, the resolver will usually append the default DNS suffix (also, the regexp only allows dotless domains that are at least 4 characters long).


  • Winner of the 2016 Presidential Election

    @DKATyler said:

    isNumber: well, maybe I can see writing this as a parseInt catch.

    @DKATyler said:
    And of course, there's still the coding style war over try/catch vs. avoid.  I'm on the avoid side of the fence.

    .NET has TryParse which remains on the avoid side of the fence.

    @DKATyler said:
    -----------------------------------------
    My first pass, I stopped reading here because I thought below was a signature.


  •  BUT WHAT ABOUT .MUSEUM!!??!?!?!?!??!!



  • @joe.edwards said:

    @DKATyler said:
    isNumber: well, maybe I can see writing this as a parseInt catch.

    @DKATyler said:
    And of course, there's still the coding style war over try/catch vs. avoid.  I'm on the avoid side of the fence.

    .NET has TryParse which remains on the avoid side of the fence.

    @DKATyler said:

    -----------------------------------------
    My first pass, I stopped reading here because I thought below was a signature.

    Except that .NEt implementations of TryParse do NOT avoid the "try/catch"...They simply wrap it...And this matters!!!!!  It drives me nuts when running a program with "Break on First Chance Exception Thrown" and a breakpoint occurs during non-exceptional (i.e. they could be predicted to happen with some regularity) conditions.

    Temember exceptions should be thrown, only in exceptional conditions. If this happens in a lower level than "yoor code" it can be even worse as significant work mus be done to avoid it. I have had to re-implement significant parts of the .NET framework for various jobs that must run without exceptions being thrown [a throw generates an event which causes a person to get paged in the middle of the night]



  • @joe.edwards said:

    @DKATyler said:
    isNumber: well, maybe I can see writing this as a parseInt catch.

    @DKATyler said:
    And of course, there's still the coding style war over try/catch vs. avoid.  I'm on the avoid side of the fence.

    .NET has TryParse which remains on the avoid side of the fence.

    @DKATyler said:

    -----------------------------------------
    My first pass, I stopped reading here because I thought below was a signature.

    Except that .NEt implementations of TryParse do NOT avoid the "try/catch"...They simply wrap it...And this matters!!!!!  It drives me nuts when running a program with "Break on First Chance Exception Thrown" and a breakpoint occurs during non-exceptional (i.e. they could be predicted to happen with some regularity) conditions.

    Temember exceptions should be thrown, only in exceptional conditions. If this happens in a lower level than "yoor code" it can be even worse as significant work mus be done to avoid it. I have had to re-implement significant parts of the .NET framework for various jobs that must run without exceptions being thrown [a throw generates an event which causes a person to get paged in the middle of the night]



  • @joe.edwards said:

    .NET has TryParse which remains on the avoid side of the fence.
     

    Didn't know that.

    @ender said:

    @DKATyler said:
    isEmail: Verifies it at
    least looks like a valid email address
    Except it doesn't. It'll
    reject foo+bar@gmail.com (a valid e-mail address) and accept
    .foo.@bar.com, whatever@11.22.33.44 and bar@quux (which are all
    invalid).

    IPs are also valid, but true enough, the RFC standard email addy regex is not pretty.  Usually a contains ("@") is good enough and I usually put/expect something like this on a form purely for the tab monkeys that start typing on the wrong input.

    @mikeTheLiar said:

    If you ever find yourself writing a regex to
    validate whether something is a number or not, stop. You have a hammer.
    Not everything is a nail.
     

    Granted.  I also come across/am guilty of the following: I have a Hammer in hand, my screwdriver is in the tool-chest all the way in the garage.  Just knock it in & keep going, not worth the trouble to fetch a screwdriver.  The code you pasted is copy-paste with the regex line changed.

     

     

     



  • @DKATyler said:

    The code you pasted is copy-paste with the regex line changed.

    If you find yourself copy-pasting a method three times, changing one line, stop. You're being a moron. Take a moment, think about what the hell you're doing, and figure out a better way to do it.



  • @DKATyler said:

    IPs are also valid
    Bare IPs aren't valid - they have to be enclosed in []...]



  • @mikeTheLiar said:

    @DKATyler said:
    The code you pasted is copy-paste with the regex line changed.

    If you find yourself copy-pasting a method three times, changing one line, stop. You're being a moron. Take a moment, think about what the hell you're doing, and figure out a better way to do it.

    I do it all the time.....with one-line methods!!!!



  • @DKATyler said:

    @ender said:
    @DKATyler said:
    isEmail: Verifies it at least looks like a valid email address

    Except it doesn't. It'll reject foo+bar@gmail.com (a valid e-mail address) and accept .foo.@bar.com, whatever@11.22.33.44 and bar@quux (which are all invalid).

    IPs are also valid, but true enough, the RFC standard email addy regex is not pretty. Usually a contains ("@") is good enough and I usually put/expect something like this on a form purely for the tab monkeys that start typing on the wrong input.

    pants is a valid email address. socks@ is an invalid email address.



  • Re: [-a-zA-Z0-9_+.]+@[-a-zA-Z0-9_+.]+

    Since we've talked about it before, I'll repeat what I said: you follow the standard as long as it's not completely bonkers or clearly designed for another time AND not everyone else is also ignoring it. When a standard allows comments inside email addresses ( "john.smith(da best)@outlook(cuz gmail sucks).com"), or things that are completely unnecessary and nobody uses or expects ( "what;><:[the]".."fuck @\"is this shit"@domain.com ), then it's the "standard" that's wrong and should go fuck itself.

    The ideal actions in this case are: search to see if anyone has written a recommendation on what to do (a better standard), check what other people are doing, make and publish a new standard yourself (if you have any kind of relevancy on the internet), or if everything else fails just do whatever you think is better (but try to document your choice somewhere).

    Same thing with Linux file names: don't spend an hour modifying your program to deal with newlines in filenames, just add a check to reject them.



  • @TheCPUWizard said:

    Except that .NEt implementations of TryParse do NOT avoid the "try/catch"...They simply wrap it...And this matters!!!!!  It drives me nuts when running a program with "Break on First Chance Exception Thrown" and a breakpoint occurs during non-exceptional (i.e. they could be predicted to happen with some regularity) conditions.

    You're usually spot on with when you say something, but I just looked at Decimal.TryParse with Reflector and it doesn't catch an exception, it uses unsafe C to go through the string character by character and returns false if it sees something it doesn't like. It's even really careful to not create extra copies of the string as it does its thing.



  • @Jaime said:

    @TheCPUWizard said:

    Except that .NEt implementations of TryParse do NOT avoid the "try/catch"...They simply wrap it...And this matters!!!!!  It drives me nuts when running a program with "Break on First Chance Exception Thrown" and a breakpoint occurs during non-exceptional (i.e. they could be predicted to happen with some regularity) conditions.

    You're usually spot on with when you say something, but I just looked at Decimal.TryParse with Reflector and it doesn't catch an exception, it uses unsafe C to go through the string character by character and returns false if it sees something it doesn't like. It's even really careful to not create extra copies of the string as it does its thing.

    Jamie, thanks.. I am traveling with only a (non-programming)  tablet....let me check my list when I get back home tomorrow night. I know that there have been changes over the versions and not all were implemented the same way



  • @DKATyler said:

    Finally one of mike's post annoys me enough to post.  Why do you take offense to regex for these cases?

    isGUID: Tests for a valid guid format, a .net built-in function isn't around till .net4 according to a quick google, that's only 3 years ago.

    isEmail: Verifies it at least looks like a valid email address, what, would you honestly do a try{sendEmail();} catch{SMTPHost email could not be sent} instead? I don't see a built-in alternate but I'm not from the .net world.

    isNumber: well, maybe I can see writing this as a parseInt catch.

    -----------------------------------------

    And of course, there's still the coding style war over try/catch vs. avoid.  I'm on the avoid side of the fence.

    (Disclaimer, I use regex with some frequency, and some parts of the code are stable enough that I can even write some of the requisite boiler-plate code using regex: "$1$2$3$4$5$6$7 $3 $5:$2>" was the replace expression of a find/replace operation I was doing at the time.)

    That's great. Why aren't these functions in module models or somewhere else relevant? What is this god class crap?



  • @Shoreline said:

    That's great. Why aren't these functions in module models or somewhere else relevant? What is this god class crap?

    Or the fact that all of these methods could be rewritten in one line.


  • Discourse touched me in a no-no place

    @mikeTheLiar said:

    Actually, that would have been easy. <font face="Lucida Console" size="2">bool IsEmail(string goFuckYourselfAssholeWhoWroteThisMethod) { return true; }</font>
    Check for: at least one non-whitespace, non-@ character, “@”, at least one non-whitespace, non-@ character, “.”, at least one non-whitespace, non-@ character. You don't want any spaces, you want exactly one @, and you want a qualified host name (but don't bother validating that; that requires a DNS check). That only causes problems with people who have empty mailbox names (is that legal?), people who want to use a locally-resolving host, or misguided fools who insist on specifying their mail host via IPv6, but fuck 'em. Oh, and for assholes who just spam random crap in form fields.



  • @mikeTheLiar said:

    Stumbled across these three methods in a ~10K LOC God-Object.

    I've seen that IsEmail method before. Specifically, when I was ripping it out of an application I was maintaining. It must have good SEO.

    @dkf said:

    Check for: at least one non-whitespace, non-@ character, “@”, at least one non-whitespace, non-@ character, “.”, at least one non-whitespace, non-@ character. You don't want any spaces, you want exactly one @, and you want a qualified host name (but don't bother validating that; that requires a DNS check). That only causes problems with people who have empty mailbox names (is that legal?), people who want to use a locally-resolving host, or misguided fools who insist on specifying their mail host via IPv6, but fuck 'em. Oh, and for assholes who just spam random crap in form fields.

    Whitespace is perfectly legal in local parts provided it's quoted. So is an empty local part. And an @.



  • @pjt33 said:

    Whitespace is perfectly legal in local parts provided it's quoted. So is an empty local part. And an @.
     

    Sure. But find me one online service, just one, that accepts "John Smith"@example.com as a sign up email. Because I just checked a dozen and couldn't. So whoever has an email address with spaces and @s in it clearly doesn't care about actually using it, so they can live without using my website either.



  • @anonymous234 said:

    Sure. But find me one online service, just one, that accepts "John Smith"@example.com as a sign up email. Because I just checked a dozen and couldn't. So whoever has an email address with spaces and @s in it clearly doesn't care about actually using it, so they can live without using my website either.

    This way anarchy lies. Next thing you know, you'll be playing videos in random order or doing work on your UI thread. Madness!



  • @anonymous234 said:

    Sure. But find me one online service, just one, that accepts "John Smith"@example.com as a sign up email. Because I just checked a dozen and couldn't. So whoever has an email address with spaces and @s in it clearly doesn't care about actually using it, so they can live without using my website either.

    As far as I'm concerned, there are two reasonable options. The first one is to Do It Right ™. However, it does have some downsides. The other one is to leave it to your mailer. Since this is a .Net thread, that would be
    		public static bool IsUsableEmail(string addr)
    {
    try { new System.Net.Mail.MailAddress(addr); return true; }
    catch { return false; }
    }

    If that should give false negatives then you wouldn't be able to send mail to those addresses anyway, so you're just detecting problems earlier rather than later. If it should give false positives (as it does), then maybe that's an acceptable compromise for ease of maintenance.


  • Winner of the 2016 Presidential Election

    @boomzilla said:

    doing work on your UI thread.

    Quiet. You'll bring bridget99 back.



  • @boomzilla said:

    doing work on your UI thread.

    The secret to avoiding doing work on the UI thread is to run every instruction on a separate thread. Of course, this causes a few race conditions, so we need to add mutexes and semaphores to prevent foo.getX() from running before foo is loaded from memory.

    The end result is that our program runs 8155552 times slower, but with none of that awful UI jitter.


  • Discourse touched me in a no-no place

    @Ben L. said:

    The secret to avoiding doing work on the UI thread is to run every instruction on a separate thread.
    The secret to avoiding doing work on the UI thread is to put it all In The Cloud. Each time the mouse is moved, allocate a VM on a cluster in another continent in order to process the update. That gives you a total ability to scale out to handling a practically-infinite number number of mouse clicks (credit limit permitting).


  • Winner of the 2016 Presidential Election

    @dkf said:

    @Ben L. said:
    The secret to avoiding doing work on the UI thread is to run every instruction on a separate thread.
    The secret to avoiding doing work on the UI thread is to put it all In The Cloud. Each time the mouse is moved, allocate a VM on a cluster in another continent in order to process the update. That gives you a total ability to scale out to handling a practically-infinite number number of mouse clicks (credit limit permitting).

    The great part of this is that, due to variable latency of the RPC requests, the events are processed in a chaotic order.



  • @pjt33 said:

    It must have good SEO.

    One of the last things my predecessor (and author of the above methods) handed me before walking out. Yes, that does say 2008.



  • @anonymous234 said:

    @pjt33 said:

    Whitespace is perfectly legal in local parts provided it's quoted. So is an empty local part. And an @.
     

    Sure. But find me one online service, just one, that accepts "John Smith"@example.com as a sign up email. Because I just checked a dozen and couldn't. So whoever has an email address with spaces and @s in it clearly doesn't care about actually using it, so they can live without using my website either.

    Not anymore.  Yahoo used to.  My Yahoo identity actually dates back to before they had webmail, and so it contains a space.  Unfortuanately, a lot of Yahoo tools couldn't handle the login with a space correctly.  They no longer let me log in with the space version of the name.

     You know what they changed it to?  A nice pat on the back for being with them for so long?  A soothing Underscore, or even a dash?  No.  A Plus sign.  That is right, I have to login with a freaking plus sign in the middle of the username.



  • @anonymous234 said:

    or things that are completely unnecessary and nobody uses or expects ( "what;><:[the]".."fuck @\"is this shit"@domain.com ), then it's the "standard" that's wrong and should go fuck itself.

    I forget the actual name, but one of my old clients had an email address like Jack.O'Neill@example.com. I was surprised he didn't have more issues with that apostrophe!


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.