
    ,h                        d dl mZmZ d dlmZmZmZmZmZm	Z	m
Z
mZmZmZmZmZmZ ddlZddlZddlZddlZddlmZmZmZmZ dedeee   eeef   fdZd	ed
edefdZdedefdZ G d de      Z 	 	 d)dedededede f
dZ!d*dededdfdZ"dededededdf
dZ# G d de      Z$d+ded ed!ede$fd"Z%d#eddfd$Z& G d% d&e      Z'd'ede'fd(Z(y),   )EmailSyntaxErrorValidatedEmail)EMAIL_MAX_LENGTHLOCAL_PART_MAX_LENGTHDOMAIN_MAX_LENGTHDOT_ATOM_TEXTDOT_ATOM_TEXT_INTLATEXT_REATEXT_INTL_DOT_REATEXT_HOSTNAME_INTL
QTEXT_INTLDNS_LABEL_LENGTH_LIMITDOT_ATOM_TEXT_HOSTNAMEDOMAIN_NAME_REGEXDOMAIN_LITERAL_CHARS    N)OptionalTuple	TypedDictUnionemailreturnc                    dt         dt        t         df   dt        t         t         f   fd}dt         dt        t         t        f   fd} || d      \  }}|j                  d      r|j	                         } ||      \  }}|sb|D ch c],  }t        j                  |      s|d	k7  s|d
k(  rt        |      . }}|r)t        ddj                  t        |            z   d
z         t        |d       d|vrt        d      |j	                  d	      }|d   dk7  rt        d      |dd  j	                  d      }	 ||	d      \  }
}nd }||}}
|j                  d      r|dd  } ||
      \  }
}||
||fS c c}w )Ntextspecials.r   c                 V   d}d}d}t        |       D ]b  \  }}t        j                  d| |d        d   |k7  r||z  }+|r||z  }|dk(  r|sd}<|dk(  r|sd}d}Hd}K|dk(  r||z  }d}X||v r n||z  }d t        |      t        |       k(  rt	        d      | t        |      d  }||fS )	NF NFCr   \T"z%An email address must have an @-sign.)	enumerateunicodedata	normalizelenr   )r   r   inside_quoteescaped	left_partic
right_parts           X/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/email_validator/syntax.py split_string_at_unquoted_specialz5split_email.<locals>.split_string_at_unquoted_special1   s    
 	dO 	DAq $$UDH5a8A=Q	Q	9W"G#Xg#(L#G#GcQ	#hQ	5	8 y>SY&"#JKK #i./*
*$$    c           
         d}d}d}t        |       D ]v  \  }}|r]|r||z  }d}|dk(  rd}|dk(  r@|t        |       dz
  k7  r*t        ddj                  d	 | |dz   d  D              z          ||fS ||z  }e|d
k(  r|dk(  rd}r||z  }x ||fS )NFr   r   Tr    r   z,Extra character(s) found after close quote: , c              3   2   K   | ]  }t        |        y wNsafe_character_display.0r)   s     r+   	<genexpr>z=split_email.<locals>.unquote_quoted_string.<locals>.<genexpr>o   s     :kYZ;QRS;T:k   r   )r!   r$   r   join)r   quotedr&   valuer(   r)   s         r+   unquote_quoted_stringz*split_email.<locals>.unquote_quoted_string]   s    
 dO 	DAqQJE#G$Y"G#XCIM)./]15:k^bcdghchci^j:k1k0l m m f} QJEaAH
#	& f}r-   )@<r=    .z>The display name contains invalid characters when not quoted: r/   Tallow_space>zoAn open angle bracket at the start of the email address has to be followed by a close angle bracket at the end.z0There can't be anything after the email address.r   )r<   r<   )strr   bool
startswithrstripr
   matchr3   r   r8   sortedcheck_unsafe_chars)r   r,   r;   r'   r*   display_namedisplay_name_quotedr)   	bad_chars	addr_spec
local_partdomain_partis_quoted_local_parts                r+   split_emailrR      s   H*%s *%eCHo *%RWX[]`X`Ra *%XC E#t),< < =UJOIz S!$$&	 -B),L)) # & q)a3h18 'q)I 
 &'gjnjsjstz  |E  uF  kG  (G  JM  (M  N  N 	<T: j "  $U  V  V&&s+
b>S "#UVV qrN))#.	 #C9f"U
K
 "+ZK
c"!!"o (=Z'H$J$[2FFFKs   1E4addrlimitc                 B    t        |       |z
  }|dkD  rdnd}d| d| dS )zEHelper function to return an error message related to invalid length.r   sr   (
 character
 too many))r$   )rS   rT   diffsuffixs       r+   get_length_reasonr\      s2    t9uD1HS"FtfJvhj11r-   r)   c                     | dk(  rd|  dS t        j                  |       d   dv rt        |       S t        |       dk  rdt        |       dj	                         }ndt        |       dj	                         }t        j
                  | |      S )	Nr   r    r   LNPSi  zU+04x08x)r"   categoryreprorduppername)r)   hs     r+   r3   r3      s    DyA3bzAq!%99Aw 1vQ##%Q##% Aq!!r-   c                   2    e Zd ZU eed<   ee   ed<   eed<   y)LocalPartValidationResultrO   ascii_local_partsmtputf8N)__name__
__module____qualname__rD   __annotations__r   rE    r-   r+   rl   rl      s    Osm#Nr-   rl   localallow_smtputf8allow_empty_localquoted_local_partc                 B   t        |       dk(  r|st        d      | | ddS t        |       t        kD  r t        | t              }t        d| d      t	        j
                  |       r| | ddS d}d}t        j
                  |       rj|sc| D ch c]"  }t        j
                  |      st        |      $ }}|r)t        d	d
j                  t        |            z   dz         t        d      d}d}n|r| D ch c]"  }t        j
                  |      st        |      $ }}|r)t        dd
j                  t        |            z   dz         | D ch c]#  }dt        |      cxk  rdk  sn t        |      % }}|r-d}|s)t        d	d
j                  t        |            z   dz         d}|rQt        | |dk(         	 | j                  d       |dk(  rdt!        j"                  dd|       z   dz   } | |s| |dS d|dS | D ch c]"  }t%        j
                  |      st        |      $ }}|r)t        dd
j                  t        |            z   dz         t'        | ddd       t        d      c c}w c c}w c c}w # t        $ r}	t        d      |	d}	~	ww xY wc c}w )z;Validates the syntax of the local part of an email address.r   z*There must be something before the @-sign.F)rO   rm   rn   rT   z0The email address is too long before the @-sign r?   NzBInternationalized characters before the @-sign are not supported: r/   zAInternationalized characters before the @-sign are not supported.zdot-atomTzKThe email address contains invalid characters in quotes before the @-sign:     ~   r9   r@   utf8z0The email address contains an invalid character.r    z(["\\])z\\\1zAThe email address contains invalid characters before the @-sign: z(An email address cannot start with a {}.z@An email address cannot have a {} immediately before the @-sign.is_hostnamez@The email address contains invalid characters before the @-sign.)r$   r   r   r\   r   rH   r	   r
   r3   r8   rI   r   rg   rJ   encode
ValueErrorresubr   check_dot_atom)
rt   ru   rv   rw   reasonvalidrequires_smtputf8r)   rM   es
             r+   validate_email_local_partr      s    5zQ "#OPP
   %
 	
 5z))"50EF!QRXQYYZ[\\ 5!   %
 	
  E& ~~a( 'q)I 
 &'knrnwnwx~  @I  yJ  oK  (K  NQ  (Q  R  R ##fgg   
 
##A& #1%
	 

 "#psws|s|  ~D  EN  ~O  tP  $P  SV  $V  W  W
 
#a&'C' #1%
	 

  $ "&'knrnwnwx~  @I  yJ  oK  (K  NQ  (Q  R  R   	5u/@B
	^LL  H"&&We<<sBE  ->)
 	
DH)
 	
  &&q) 	q!I 
 beienenouv  pA  fB   B  EH   H  I  	I 5D  GI  W\  ] ]
^^G0

<  	^"#UV\]]	^,s0   'I08'I5(I:>I? 'J?	JJJrV   rA   c           	         t               }t        |       D ]  \  }}t        j                  |      }|d   dv r#|d   dk(  r|dk(  s1|j	                  |       C|dk(  r|rK|j	                  |       ]|d   dk(  r|j	                  |       w|d   dk(  r|j	                  |       |j	                  |        |r0t        ddj                  d	 t        |      D              z   d
z         y )Nr   r^   MZsZCz.The email address contains unsafe characters: r/   c              3   2   K   | ]  }t        |        y wr1   r2   r4   s     r+   r6   z%check_unsafe_chars.<locals>.<genexpr>  s     *`+A!+D*`r7   r?   )setr!   r"   re   addr   r8   rI   )rV   rA   rM   r(   r)   re   s         r+   rJ   rJ   r  s    I! *1''*A;..a[C
 Ava  a a[C
 MM!a[C MM! MM!U*V O!%*`fU^N_*`!` acf g h 	h r-   labelstart_descr	end_descrr~   c                    | j                  d      rt        |j                  d            | j                  d      rt        |j                  d            d| v rt        d      |rj| j                  d      rt        |j                  d            | j                  d      rt        |j                  d            d| v sd| v rt        d	      y y )
Nr?   periodz..z2An email address cannot have two periods in a row.-hyphenz.-z-.zFAn email address cannot have a period and a hyphen next to each other.)endswithr   formatrF   )r   r   r   r~   s       r+   r   r     s    ~~cy//9::{11(;<<u}STT>>#"9#3#3H#=>>C ";#5#5h#?@@5=DEM"#kll * r-   c                   "    e Zd ZU eed<   eed<   y)DomainNameValidationResultascii_domaindomainN)ro   rp   rq   rD   rr   rs   r-   r+   r   r     s    Kr-   r   r   test_environmentglobally_deliverablec                    | D ch c]"  }t        j                  |      st        |      $ }}|r)t        ddj	                  t        |            z   dz         t        |        | }	 t        j                  | dd      } | D ch c]"  }t        j                  |      st        |      $ }}|r)t        d	dj	                  t        |            z   dz         t        | d
dd       | j                  d      D ]2  }t        j                  d|t        j                        s)t        d       t        j                  |       r| }nH	 dj	                  d | j                  d      D              }t        j                  |      st        d      t        |      t         kD  rR||k(  r t#        |t               }	t        d|	 d      t        |      t         z
  }
|
dk(  rdnd}t        d|
 d| d      |j                  d      D ]4  }t        |      t$        kD  st#        |t$              }	t        d|	 d       |r6d|vr|dk(  r|st        d      t'        j(                  |      st        d      ddlm} |D ].  }|dk(  r|r||k(  s|j/                  d|z         s%t        d        	 t        j0                  |j3                  d!            }| D ch c]"  }t        j                  |      st        |      $ }}|r)t        ddj	                  t        |            z   dz         t        |        	 t        j2                  |       ||d$S c c}w # t        j                  $ r}t        d| d      |d}~ww xY wc c}w # t        j                  $ r}t        d| d      |d}~ww xY w# t        j                  $ r}t        d"| d      |d}~ww xY wc c}w # t        j                  $ r}t        d#| d      |d}~ww xY w)%z<Validates the syntax of the domain part of an email address.z7The part after the @-sign contains invalid characters: r/   r?   F)
std3_rulestransitionalz7The part after the @-sign contains invalid characters ().NzSThe part after the @-sign contains invalid characters after Unicode normalization: z?An email address cannot have a {} immediately after the @-sign.z&An email address cannot end with a {}.Tr}   z
(?!xn)..--zAn email address cannot have two letters followed by two dashes immediately after the @-sign or after a period, except Punycode.c              3   d   K   | ](  }t        j                  |      j                  d        * yw)asciiN)idnaalabeldecode)r5   r   s     r+   r6   z-validate_email_domain_name.<locals>.<genexpr>
  s,      $ E"))'2$s   .0z&The part after the @-sign is invalid (zSThe email address contains invalid characters after the @-sign after IDNA encoding.ry   z/The email address is too long after the @-sign r   r   rV   z0The email address is too long after the @-sign ( bytez too many after IDNA encoding).zDAfter the @-sign, periods cannot be separated by so many characters testz@The part after the @-sign is not valid. It should have a period.zRThe part after the @-sign is not valid. It is not within a valid top-level domain.)SPECIAL_USE_DOMAIN_NAMESz[The part after the @-sign is a special-use or reserved name that cannot be used with email.r   z-The part after the @-sign is not valid IDNA (zXThe part after the @-sign became invalid after normalizing to international characters ()r   r   )r   rH   r3   r   r8   rI   rJ   r   uts46_remap	IDNAErrorr   splitr   Ir   r$   r   r\   r   r   searchr   r   r   r   r   )r   r   r   r)   rM   original_domainr   r   r   r   rZ   rV   r   ddomain_i18ns                  r+   validate_email_domain_namer     s    "((+ 	q!I 
 X[_[d[dekluev[wwz}}~~ v Og!!&UO "((+ 	q!I 
 tw{  xA  xA  BH  IR  BS  xT   T  WZ   Z  [  	[ 6\  _G  UY  Z c" g88M5"$$/"  $f  g  gg ##F+	Z88 $#\\#.$ L &++L9"#xyy <,,?*&|;LMF"%TU[T\\]#^__|$'88DaiSA"%UVZU[[`ab`c  dC  $D  E  E ##C( uu:..&u4JKF"%ijpiqqr#sttu
  l"LF,BGW"#eff !''5"#wxx +% B;+1 5 5cAg >"  $A  B  BB ]kk,"5"5g">? "((+ 	q!I 
 X[_[d[dekluev[wwz}}~~vHK  % g2 >> g!XYZX[[]^_effg
Z ~~ 	Z"%KA3b#QRXYY	ZL >> ]!NqcQSTU[\\] >> H!yz{y||~  A  GH  	HHsq   'M'M 'M<'N *$N, 'O2O M9$M44M9N)N$$N),O?OOP/O??Paddrinfoc                    | j                   d f| j                  df| j                  xs | j                  xs ddz   | j                  z   dfg}|D ]  \  }}t        |      }t        |j                  d            }|t        z
  }|dkD  s:|||k(  rt        |t              }n]|Ft        d |D              }t        d	||z        }|d	kD  rd
nd}	||k(  r
d| d|	 d}n"d| d| d|	 d}n|d	kD  rd
nd}	|d| d|	 dz  }t        d| d       y )Nzafter normalizationr   r<   z9when the part after the @-sign is converted to IDNA ASCIIr|   r   ry   c              3   P   K   | ]  }t        |j                  d                yw)r|   N)r$   r   r4   s     r+   r6   z(validate_email_length.<locals>.<genexpr>  s     ?Q3qxx/0?s   $&r   rV   rW   rX   rY   r   z (r   zThe email address is too long r?   )original
normalizedrm   rO   r   r$   r   r   r\   maxr   )
r   addresses_to_checkrS   r   addr_lenaddr_utf8_lenrZ   mbpcmcharsr[   s
             r+   validate_email_lengthr   |  se   2 
		D!			34

#
#
@x':':
@bC	G(J_J_	_  b]  	^ + Oft9DKK/0//!8~(m"; +47GH ?$??Q- $qbT> j
CF $z&LF
 !%qbBtfE&<<"%CF81#MNN=Or-   c                   T    e Zd ZU eej
                  ej                  f   ed<   eed<   y)DomainLiteralValidationResultdomain_addressr   N)	ro   rp   rq   r   	ipaddressIPv4AddressIPv6Addressrr   rD   rs   r-   r+   r   r     s#    )//1F1FFGGKr-   r   domain_literalc                 X   t        j                  d|       r	 t        j                  |       }|d| ddS | j                  d      r,	 t        j                  | dd        }|d|j                   ddS d| vrt        d      | D ch c]"  }t        j                  |      st        |      $ }}|r)t        ddj                  t        |            z   dz         t        d      # t        $ r}t        d| d      |d }~ww xY w# t        $ r}t        d	| d
      |d }~ww xY wc c}w )Nz
^[0-9\.]+$zRThe address in brackets after the @-sign is not valid: It is not an IPv4 address (z') or is missing an address literal tag.[])r   r   zIPv6:   z<The IPv6 address in brackets after the @-sign is not valid (r   z[IPv6::z\The part after the @-sign in brackets is not an IPv4 address and has no address literal tag.zCThe part after the @-sign contains invalid characters in brackets: r/   r?   zNThe part after the @-sign contains an invalid address literal tag in brackets.)r   rH   r   r   r   r   rF   r   
compressedr   r3   r8   rI   )r   rS   r   r)   rM   s        r+   validate_email_domain_literalr     s    
xx~.	k((8D #$qk
 	
   )	p(();<D #t/q1
 	
 . }~~  #))!, 	q!I 
 dgkgpgpqw  yB  rC  hD   D  GJ   J  K  	K k
llY  	k"%wxywz  {b  $c  d  jk  k	k  	p"%abcaddf#ghnoo	p*s5   C% D 'D'%	D.C>>D	D$DD$)TFF)F)FT))exceptions_typesr   r   rfc_constantsr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r"   r   r   typingr   r   r   r   rD   rE   rR   intr\   r3   rl   r   rJ   r   r   r   r   r   r   rs   r-   r+   <module>r      s   >\ \ \ \ 
    4 4cGs cGuXc]Cd%BC cGL2C 2 2 2"c "c ""	  bg8=^_S ^_$ ^_Z^ ^_15^_B[^_B1h# 1hD 1hT 1hhm# mC mC md mW[ m& 
{s {d {bf {  sM {|<ON <Ot <O~I 
9m# 9m:W 9mr-   