Re: What this means "(\w|-)+@\w"? [message #174789 is a reply to message #174788] |
Fri, 08 July 2011 06:05 |
Eli the Bearded
Messages: 22 Registered: April 2011
Karma:
|
Junior Member |
|
|
In comp.lang.php, Thomas 'PointedEars' Lahn <php(at)PointedEars(dot)de> wrote:
> Eli the Bearded wrote:
>> [0-9a-zA-z] broken attempt to match a number or letter
>> will also match [ ] \ ^ _ `
> Now come on, that is probably just a typo. Make the last `z' a `Z'
> (uppercase) and it will not match those extra characters (it will
> match too few addresses, though).
Yeah, but did you notice the strtolower() later on? It's just broken.
>> uses this email address precisely because it gets rejected by bad
>> verifiers
>
> ACK. Good to see it passed mine (and was subsequently SMTP-checked
> as being OK) :)
>
> atext="[A-Za-z0-9!#\$%&'*+/=?^_\`{|}~-]"
> dot_atom_text="$atext+(\\.$atext+)*"
RFC822 had that same dor rule, but I've never encountered mail
software that would reject an address with a final dot, eg
something like: <john.johnson.jr.@jrsite.example>
> dot_atom=$dot_atom_text
>
> if [ -z "`echo "$i" | egrep -e "${dot_atom}@${dot_atom}"`" ]; then
Hostnames have a pretty rigid syntax that can easily be checked.
Even punycoded international domain names will validate with this:
labeltext="[A-Za-z0-9][A-Za-z0-9-]{,62}"
hosttext="$labeltext(\\.$labeltext)*\\.?"
(I ignore the overall hostname length limit there. I'm pretty sure
it is 255 with dots.)
Trailing dots are used to anchor a hostname, legal but rarely seen.
If you owned a TLD and wanted to use it directly for email, the
trailing anchor dot would be a good idea: <vanity@mytld.>
With wildcard DNS, you can have some resolvers get an IP address
for invalid names, most often this seems to happen with underscores
used instead of hyphens. I figure those people are screwed and don't
worry about them.
> It is a shell script, but you can probably see how it works. It is derived
> directly from RFC 2822, section 3.4.1, which was current at the time it was
> written. Do I need to update it to RFC 5322 in any way?
I haven't looked at that closely enough to tell you.
Elijah
------
non-punycoded international domains are just for show
|
|
|