Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Cyborg)
  • No Skin
Collapse
Brand Logo

CIRCLE WITH A DOT

  1. Home
  2. Uncategorized
  3. me: i need to validate some email addresses, so i am going to write a quick regex.

me: i need to validate some email addresses, so i am going to write a quick regex.

Scheduled Pinned Locked Moved Uncategorized
44 Posts 37 Posters 0 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • foo__@mastodon.socialF foo__@mastodon.social

    @nixCraft regex might be hard, the email addresses RFC is "wild", cf.

    Link Preview Image
    Email is Easy

    Everyone knows what an email address is, right?

    favicon

    e-mail.wtf (e-mail.wtf)

    kasperd@westergaard.socialK This user is from outside of this forum
    kasperd@westergaard.socialK This user is from outside of this forum
    kasperd@westergaard.social
    wrote last edited by
    #25

    The answer that quiz gives on question 7 is not how I read the RFC. I looked at both RFC 821 and RFC 5321, neither permits spaces in an unqouted local-part.

    project1enigma@chaos.socialP 1 Reply Last reply
    0
    • nixcraft@mastodon.socialN nixcraft@mastodon.social

      me: i need to validate some email addresses, so i am going to write a quick regex. how hard can it be?

      *4 hours later*
      me. i now have 2 problems and one of them is that I've accidentally summoned an ancient daemon. wht the actual fuck

      S This user is from outside of this forum
      S This user is from outside of this forum
      spacelifeform@infosec.exchange
      wrote last edited by
      #26

      @nixCraft

      Did you find the needle in the haystack yet? /s

      1 Reply Last reply
      0
      • kasperd@westergaard.socialK kasperd@westergaard.social

        The answer that quiz gives on question 7 is not how I read the RFC. I looked at both RFC 821 and RFC 5321, neither permits spaces in an unqouted local-part.

        project1enigma@chaos.socialP This user is from outside of this forum
        project1enigma@chaos.socialP This user is from outside of this forum
        project1enigma@chaos.social
        wrote last edited by
        #27

        @kasperd @foo__ @nixCraft

        I'd think in a dot-atom spaces around the dot would be ok?

        That's foo . (Comment) bar @ something . com

        At least in "obsolete" syntax.

        project1enigma@chaos.socialP 1 Reply Last reply
        0
        • project1enigma@chaos.socialP project1enigma@chaos.social

          @kasperd @foo__ @nixCraft

          I'd think in a dot-atom spaces around the dot would be ok?

          That's foo . (Comment) bar @ something . com

          At least in "obsolete" syntax.

          project1enigma@chaos.socialP This user is from outside of this forum
          project1enigma@chaos.socialP This user is from outside of this forum
          project1enigma@chaos.social
          wrote last edited by
          #28

          @kasperd @foo__ @nixCraft

          Probably even with line folds.

          project1enigma@chaos.socialP 1 Reply Last reply
          0
          • project1enigma@chaos.socialP project1enigma@chaos.social

            @kasperd @foo__ @nixCraft

            Probably even with line folds.

            project1enigma@chaos.socialP This user is from outside of this forum
            project1enigma@chaos.socialP This user is from outside of this forum
            project1enigma@chaos.social
            wrote last edited by
            #29

            @kasperd @foo__ @nixCraft

            Depending on use case you could make a regex for a reasonable subset still as long as it's ok for you to reject some theoretically valid addresses.

            project1enigma@chaos.socialP 1 Reply Last reply
            0
            • project1enigma@chaos.socialP project1enigma@chaos.social

              @kasperd @foo__ @nixCraft

              Depending on use case you could make a regex for a reasonable subset still as long as it's ok for you to reject some theoretically valid addresses.

              project1enigma@chaos.socialP This user is from outside of this forum
              project1enigma@chaos.socialP This user is from outside of this forum
              project1enigma@chaos.social
              wrote last edited by
              #30

              @kasperd @foo__ @nixCraft

              (Ok, my previous example was RFC 5322, for headers, not 5321 for addresses as used in the SMTP transaction...)

              1 Reply Last reply
              0
              • nixcraft@mastodon.socialN nixcraft@mastodon.social

                me: i need to validate some email addresses, so i am going to write a quick regex. how hard can it be?

                *4 hours later*
                me. i now have 2 problems and one of them is that I've accidentally summoned an ancient daemon. wht the actual fuck

                qgustavor@urusai.socialQ This user is from outside of this forum
                qgustavor@urusai.socialQ This user is from outside of this forum
                qgustavor@urusai.social
                wrote last edited by
                #31

                @nixCraft Either you use something simple like .*@.*\..* (at least an at-sign and a dot after it) and send an e-mail with an link or you will summon a debate war on if the complete e-mail standards should be followed or not.

                And, if you choose to follow the standards, I have to warn you (and I guess some people had warned you already) that most e-mail servers do not follow the standard (like Cloudflare).

                On the other hand, I just sent a message from "example+';DROP/**/TABLE/**/users;#"@gmail.com to example@some-domain-of-mine and it arrived. I hope you never need to deal with addresses like those.

                kawazoe@transfem.socialK 1 Reply Last reply
                0
                • nixcraft@mastodon.socialN nixcraft@mastodon.social

                  me: i need to validate some email addresses, so i am going to write a quick regex. how hard can it be?

                  *4 hours later*
                  me. i now have 2 problems and one of them is that I've accidentally summoned an ancient daemon. wht the actual fuck

                  iliaf@infosec.exchangeI This user is from outside of this forum
                  iliaf@infosec.exchangeI This user is from outside of this forum
                  iliaf@infosec.exchange
                  wrote last edited by
                  #32

                  @nixCraft My experience tells me that if you have a problem and you solve it with regular expressions, you have two problems.

                  1 Reply Last reply
                  0
                  • nixcraft@mastodon.socialN nixcraft@mastodon.social

                    me: i need to validate some email addresses, so i am going to write a quick regex. how hard can it be?

                    *4 hours later*
                    me. i now have 2 problems and one of them is that I've accidentally summoned an ancient daemon. wht the actual fuck

                    negative12dollarbill@techhub.socialN This user is from outside of this forum
                    negative12dollarbill@techhub.socialN This user is from outside of this forum
                    negative12dollarbill@techhub.social
                    wrote last edited by
                    #33

                    @nixCraft
                    This reads like @cstross parody fiction and I mean that as a compliment.

                    1 Reply Last reply
                    0
                    • nixcraft@mastodon.socialN nixcraft@mastodon.social

                      me: i need to validate some email addresses, so i am going to write a quick regex. how hard can it be?

                      *4 hours later*
                      me. i now have 2 problems and one of them is that I've accidentally summoned an ancient daemon. wht the actual fuck

                      pseudonym@mastodon.onlineP This user is from outside of this forum
                      pseudonym@mastodon.onlineP This user is from outside of this forum
                      pseudonym@mastodon.online
                      wrote last edited by
                      #34

                      @nixCraft

                      At least the ancient demon is bound to serve you, and not eat you until it provides you with a perfect email parsing library, right?

                      1 Reply Last reply
                      0
                      • nixcraft@mastodon.socialN nixcraft@mastodon.social

                        me: i need to validate some email addresses, so i am going to write a quick regex. how hard can it be?

                        *4 hours later*
                        me. i now have 2 problems and one of them is that I've accidentally summoned an ancient daemon. wht the actual fuck

                        drangnon@hachyderm.ioD This user is from outside of this forum
                        drangnon@hachyderm.ioD This user is from outside of this forum
                        drangnon@hachyderm.io
                        wrote last edited by
                        #35

                        @nixCraft https://regex101.com/ is your friend, your very very good friend

                        1 Reply Last reply
                        0
                        • qgustavor@urusai.socialQ qgustavor@urusai.social

                          @nixCraft Either you use something simple like .*@.*\..* (at least an at-sign and a dot after it) and send an e-mail with an link or you will summon a debate war on if the complete e-mail standards should be followed or not.

                          And, if you choose to follow the standards, I have to warn you (and I guess some people had warned you already) that most e-mail servers do not follow the standard (like Cloudflare).

                          On the other hand, I just sent a message from "example+';DROP/**/TABLE/**/users;#"@gmail.com to example@some-domain-of-mine and it arrived. I hope you never need to deal with addresses like those.

                          kawazoe@transfem.socialK This user is from outside of this forum
                          kawazoe@transfem.socialK This user is from outside of this forum
                          kawazoe@transfem.social
                          wrote last edited by
                          #36

                          @qgustavor@urusai.social @nixCraft@mastodon.social you have successfully summoned a debate war by forgetting that user@localhost is a valid email, so is user@::1, and any other locally resolved name and ipv6 address. Just containing a @ is more than enough if you already try to send an email to it. 😉

                          Seriously though, enforcing a dot in the domain is probably reasonable for most publicly accessible email servers.

                          qgustavor@urusai.socialQ 1 Reply Last reply
                          0
                          • nixcraft@mastodon.socialN nixcraft@mastodon.social

                            me: i need to validate some email addresses, so i am going to write a quick regex. how hard can it be?

                            *4 hours later*
                            me. i now have 2 problems and one of them is that I've accidentally summoned an ancient daemon. wht the actual fuck

                            wyldphyre@mastodon.worldW This user is from outside of this forum
                            wyldphyre@mastodon.worldW This user is from outside of this forum
                            wyldphyre@mastodon.world
                            wrote last edited by
                            #37

                            @nixCraft Can the daemon validate things for you?

                            1 Reply Last reply
                            0
                            • nixcraft@mastodon.socialN nixcraft@mastodon.social

                              me: i need to validate some email addresses, so i am going to write a quick regex. how hard can it be?

                              *4 hours later*
                              me. i now have 2 problems and one of them is that I've accidentally summoned an ancient daemon. wht the actual fuck

                              strawhousepig@mastodon.socialS This user is from outside of this forum
                              strawhousepig@mastodon.socialS This user is from outside of this forum
                              strawhousepig@mastodon.social
                              wrote last edited by
                              #38

                              @nixCraft now toss moving between BSD/macOS and GNU into the mix.

                              1 Reply Last reply
                              0
                              • paco@infosec.exchangeP This user is from outside of this forum
                                paco@infosec.exchangeP This user is from outside of this forum
                                paco@infosec.exchange
                                wrote last edited by
                                #39

                                @meeper JavaScript you say? The same person covered that too. This one made me want to punch my computer.

                                Link Preview Image
                                new Date("wtf")

                                How well do you know JavaScript's Date class?

                                favicon

                                jsdate.wtf (jsdate.wtf)

                                @nixCraft

                                1 Reply Last reply
                                0
                                • S stealthytango@mastodon.world

                                  @nixCraft I think this is the right page from the Necronomicon: (?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])

                                  d1@autistics.lifeD This user is from outside of this forum
                                  d1@autistics.lifeD This user is from outside of this forum
                                  d1@autistics.life
                                  wrote last edited by
                                  #40

                                  @StealthyTango and it needs to be typed in a demonic font, or it won't work.

                                  1 Reply Last reply
                                  0
                                  • foo__@mastodon.socialF This user is from outside of this forum
                                    foo__@mastodon.socialF This user is from outside of this forum
                                    foo__@mastodon.social
                                    wrote last edited by
                                    #41

                                    @grepe was posted by someone on mastodon, I don't remember who 🙂 @nixCraft

                                    1 Reply Last reply
                                    0
                                    • nixcraft@mastodon.socialN nixcraft@mastodon.social

                                      me: i need to validate some email addresses, so i am going to write a quick regex. how hard can it be?

                                      *4 hours later*
                                      me. i now have 2 problems and one of them is that I've accidentally summoned an ancient daemon. wht the actual fuck

                                      jhelou@mamot.frJ This user is from outside of this forum
                                      jhelou@mamot.frJ This user is from outside of this forum
                                      jhelou@mamot.fr
                                      wrote last edited by
                                      #42

                                      @nixCraft Everytime someone uses a regex to validate an email, god kills truckloads of kittens

                                      Split on last @ ensuring the previous character is not itself an @

                                      Check if the domain part resolves, make sure you allow for international domain names.

                                      You can check if the localpart is well formed. IIRC this is not possible with regexes. You need a parser.

                                      With a valid domain, sending an email is the only real way to verify if the address is actually valid. Well formed doesn't mean accepted.

                                      1 Reply Last reply
                                      0
                                      • nixcraft@mastodon.socialN nixcraft@mastodon.social

                                        me: i need to validate some email addresses, so i am going to write a quick regex. how hard can it be?

                                        *4 hours later*
                                        me. i now have 2 problems and one of them is that I've accidentally summoned an ancient daemon. wht the actual fuck

                                        makini@mastodon.socialM This user is from outside of this forum
                                        makini@mastodon.socialM This user is from outside of this forum
                                        makini@mastodon.social
                                        wrote last edited by
                                        #43

                                        @nixCraft Reminded of this old gem:

                                        Link Preview Image
                                        1 Reply Last reply
                                        0
                                        • kawazoe@transfem.socialK kawazoe@transfem.social

                                          @qgustavor@urusai.social @nixCraft@mastodon.social you have successfully summoned a debate war by forgetting that user@localhost is a valid email, so is user@::1, and any other locally resolved name and ipv6 address. Just containing a @ is more than enough if you already try to send an email to it. 😉

                                          Seriously though, enforcing a dot in the domain is probably reasonable for most publicly accessible email servers.

                                          qgustavor@urusai.socialQ This user is from outside of this forum
                                          qgustavor@urusai.socialQ This user is from outside of this forum
                                          qgustavor@urusai.social
                                          wrote last edited by
                                          #44

                                          @kawazoe @nixCraft I got my share of self-hosted things that don't allow using localhost as the domain (e.g. Pocketbase). ::1 I guess it's invalid, it should be user@[::1]. I have a sending email address that works (sometimes) with four at-signs.

                                          1 Reply Last reply
                                          0
                                          • R relay@relay.infosec.exchange shared this topic
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups