Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Illegal Characters in Email Addresses
Message
De
17/09/2001 14:19:36
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00557301
Message ID:
00557408
Vues:
45
>I have a form with an 2 email entry boxes. I combine the 2 boxes to form the email address.
>lcEmail = .txt1.value + '@' + .txt2.value
>
>Anyone have a list of illegal characters ?
>The ones I know off the top of my head...
>'@' '/' '\' '&'
>
>Any others would be appreciated.

Hi, Chris,

I believe & is valid character, but that's not the point, now. If I recall correctly (I remember once have read the "obscure" RFC you were referred to) the standard defines proper and improper characters and also some rules that apply (for instance, an email address cannot start or end with a dot, although it's accepted in the middle of the address).

While Nadya is still busy looking for Vlad's solution, see if this fox snippet, based in what I understood from the RFC folks papers (to me is pretty hard stuff to digest, I admit), can be to some use to you:
FUNCTION ValidateEmail
LPARAMETERS cEmail
LOCAL llResult  && holds correction status so far
LOCAL llFirst && we are at the beginning of a part
LOCAL llAt && a @ is present
LOCAL llPoint && the last char scanned was a point?
LOCAL lnLoop

STORE .T. TO llResult, llFirst
STORE .F. TO llAt, llPoint

FOR lnLoop = 1 TO LEN(cEmail)

  lcChar = SUBSTR(cEmail,lnLoop,1)	
  IF lcChar = '.'
    IF llFirst OR llPoint
      llResult = .F.  && can't start with point or repeat it in sequence
    ELSE
      llPoint = .T.
    ENDIF
  ELSE
    DO CASE
    CASE lcChar = '@'
      IF llFirst OR llAt OR llPoint
        llResult = .F. && can't start with @ or repeat it
      ELSE
        STORE .T. TO llFirst, llAt  && domain name starts
        llPoint = .F.
      ENDIF
    CASE BITAND(ASC(lcChar),0x80)!=0
      llResult = .F. && non-ASCII is forbidden
    CASE AT(lcChar,' ()<>,;:\"[]')!=0
      llResult = .F. && and so are reserved characters
    CASE lcChar<' ' OR lcChar = CHR(0x7f)
      llResult = .F. && and control characters
    OTHERWISE
      STORE .F. TO llFirst, llPoint
    ENDCASE
  ENDIF

  IF !llResult
    EXIT
  ENDIF

ENDFOR

llResult = llResult AND llAt AND !llPoint AND !llFirst

RETURN llResult

ENDDEF FUNCTION
bye
----------------------------------
António Tavares Lopes
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform