News for hackers. Stuff that matters.
Re:Jolie, the service-oriented programming language by xonix on Tuesday May 07, 2024 @08:14PM (#40293000)

  email:string( regex(".*@.*\\..*") )
This is incorrect regex for email. The correct one is https://pdw.ex-parrot.com/Mail-RFC822-Address.html
Re:Jolie, the service-oriented programming language by warkdarrior on Tuesday May 07, 2024 @08:30PM (#40293107)
There is a typo on line 17.
Re:Jolie, the service-oriented programming language by UniverseHacker on Tuesday May 07, 2024 @08:23PM (#40293057)
That is an absurdly complex regex
Re:Jolie, the service-oriented programming language by Twirrim on Tuesday May 07, 2024 @08:38PM (#40293159)
Email address specs turn out to be rather complicated.

I really wish people wouldn't code their own checks rather than use already existing standards. Some languages like Java even include proper checks in their standard library: https://java.net/projects/javamail

Several jobs back I had no end of arguments with some Java devs about not writing their own checks, that kept routinely failing on legitimate addresses.

Re:Jolie, the service-oriented programming language by smrtinsert on Wednesday May 08, 2024 @01:18AM (#40294595)
It's all devs in general. As a java dev I have lost count of the number of times I have to tell any dev not to use a damn regex to validate emails.
Re:Jolie, the service-oriented programming language by soco on Wednesday May 08, 2024 @07:36AM (#40296808)
But why do you even need to validate that email? Send the subscriber a confirmation link - if they get it then it was valid, if not then it's on them to fix the situation in whatever way they find fit.
Re:Jolie, the service-oriented programming language by UniverseHacker on Wednesday May 08, 2024 @01:05PM (#40300415)
A single massive and unreadable regex isn't an appropriate way to validate a spec that complex. With its complexity it can't be logically evaluated- only tested, whereas a function that breaks the spec out into steps/parts is going to be a lot more maintainable, readable, and auditable.
Re:Jolie, the service-oriented programming language by brabel on Wednesday May 08, 2024 @02:24AM (#40294934)
It really is, I wonder if anyone has tested that extensively. It's so complex that just by reading it I don't think anyone would be able to confirm it matches the RFC correctly.
Re:Jolie, the service-oriented programming language by OJFord on Tuesday May 07, 2024 @08:45PM (#40293205)
It's a pragmatic one. It has no false negatives, and there's rarely a reason to care about false positives. (Especially not where a stricter regex would (be the only mechanism to) catch it, but a fake-but-valid address wouldn't trivially bypass it.)
Re:Jolie, the service-oriented programming language by boulos on Tuesday May 07, 2024 @10:08PM (#40293678)
At the very least, I assume .+ at the start is a better choice.

The RFC says:

     addr-spec   =  local-part "@" domain        ; global address
     atom        =  1*<any CHAR except specials, SPACE and CTLs>
     word        =  atom / quoted-string
so I think the bit in front of the @ has to be non-empty.
Re:Jolie, the service-oriented programming language by OJFord on Wednesday May 08, 2024 @08:35AM (#40297339)
Yeah, I agree, I think I'd have written that myself, but I don't think I'd reject it in review on that basis. I don't agree with sibling comment that it's 'shitty', it's trivially improved sure but it basically doesn't matter - if you want it to be actually correct you need to send an email to it for verification anyway.

Otherwise we can start saying not just not empty, it also needs no other @s etc. and before you know it we're rivalling the actually correct attempt up-thread. If you just want to catch typos, encourage entering real address (not just a space or full stop to fill mandatory field) then any basic thing is something, a compromise between legibility and how much it'll catch, we know there's a tonne of (mainly adversarial) bad input it'll miss, that's fine.

Re:Jolie, the service-oriented programming language by boulos on Thursday May 09, 2024 @12:26AM (#40305302)
Agreed. I should have said so, too.
Re:Jolie, the service-oriented programming language by petesergeant on Tuesday May 07, 2024 @11:52PM (#40294161)
I agree with the sentiment, but this one is just shitty. Switch out the stars for pluses and it’d be a lot better
Re:Jolie, the service-oriented programming language by IncreasePosts on Tuesday May 07, 2024 @08:59PM (#40293285)
At a certain point I think you're allowed to say you don't care if the person with this email address is capable of signing up or using your service:

very.”(),:;<>[]”.VERY.”very@\\ "very”[email protected]

Re:Jolie, the service-oriented programming language by immibis on Tuesday May 07, 2024 @09:28PM (#40293447)
Too bad - if that's my email address and you're rejecting it, I'm going to sue you for denying service arbitrarily and win. Not every country is the USA.
Re:Jolie, the service-oriented programming language by DEADMINCE on Tuesday May 07, 2024 @10:34PM (#40293814)
The denial of service was not intentional so I doubt you would win anything.
Re:Jolie, the service-oriented programming language by immibis on Wednesday May 08, 2024 @04:11AM (#40295546)
You'd have to fix your code, at least.
Re:Jolie, the service-oriented programming language by wk_end on Tuesday May 07, 2024 @09:43PM (#40293538)
Is there a country where this has happened?
Re:Jolie, the service-oriented programming language by petesergeant on Tuesday May 07, 2024 @11:55PM (#40294176)
> I'm going to sue you for denying service arbitrarily and win

Which country are you claiming this entirely implausible legal scenario would work in?