Viewing File: /usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pyc


)hcy@s"dZddlmZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlmZddlmZddlmZmZyddlmZWn'ek
r%dZeejZnXdd	lmZdd
lmZddlmZddl m!Z!dd
l"m#Z#y"ddl$Z$e$j%Z&e$j'Z(Wn;ek
rddl%Z%ddl)Z)e%j*Z&e)j*Z(nXye+e,fWne-k
rdZ+dZ,nXy&ddl.Z/ddl0m1Z1e+Z2Wnek
rCe,Z2nXyddl3Z3e+Z4Wnek
rse,Z4nXdZ5dZ6dZ7dZ8dZ9eedZ:ej;dej<Z=ej;dej<Z>dZ?dZ@de+dZAdZBdZCdZDej;d ZEej;d!ej<ZFd"ZGej;d#ZHd$d%ZId&ZJde,e,d'ZLd(ZMe,d)ZNdZOdZPgZQxAeOD]9ZRx0ePD](ZSeQjTeSeReQjTeReSqWqW[S[Rd@ZUdAZVejWdBZXdCZYe+dDZZe+dEZ[e+dFZ\ej;dGej<Z]e,dHZ^dIZ_e,dJZ`dKZadLebfdMYZcde,dddNZdde,dddOZeiddP6ddQ6ddR6ddS6ddT6ddV6ddW6ddY6ddZ6dd[6dd\6Zfd]Zgde+d^Zhde,d_Zid`ZjdaZkdbZldcZmddZndddeZodapdfZqddgZrdhZsdiZtdjZudkZvddlZwddmZxdnZydoZzdpZ{dqdrdsdtdudvdwdxdydzd{d|d}d~dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddgyZ|ej;dj}e|ej<Z~ej;dZej;dej<ZdZdZiadZdZdZdZe,dZiZdadZdZdZdZdZdZdZdZdS(	sMiscellaneous essential routines.

This includes actual message transmission routines, address checking and
message and address munging, a handy-dandy routine to map a function on all
the mailing lists, and whatever else doesn't belong elsewhere.

i(t
nested_scopesN(tHeaderParseError(tUnicodeType(t
whitespacetdigits(t
ascii_letterstabcdefghijklmnopqrstuvwxyz(tmm_cfg(tErrors(tSite(tSafeDict(tsyslogii(tDNSExceptiontus
s
t.t_s%\(([_a-z]\w*?)\)s?s%(\${2})|\$([_a-z]\w*)|\${([_a-z]\w*)}cCsttjtjd|dkrntjjdtjjdtjjdd}tdd||t	St
j|}x=dD]5}tjj
|d
|}tjj|rtSqWt	S(s'Return true iff list `listname' exists.R
itHTTP_FORWARDED_FORtHTTP_X_FORWARDED_FORtREMOTE_ADDRsunidentified origintmischiefs(Hostile listname: listname=%s: remote=%ss.pcks	.pck.lasts.dbs.db.lasttconfig(s.pcks	.pck.lasts.dbs.db.last(tlentretsubRtACCEPTABLE_LISTNAME_CHARACTERStostenvirontgetRtFalseR	tget_listpathtpathtjointexiststTrue(tlistnametremotetbasepathtexttdbfile((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pytlist_existsgs
$

cCs
tjS(s8Return the names of all lists in default list directory.(R	t
get_listnames(((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pyt
list_namessiFc	Cszd}tjd|}xW|D]O}g}t}x|jtD]}|s`|j|qAn|r|dtkrt}	nt}	|r|	r|djd||d<n
|j||	}qAWx|D]}x|rUt||kr|}d}nJ|}
x*|
dkr0||
tkr0|
d8}
qW|
}x*|dkrc||tkrc|d8}q:W|dkr|}x0|t|kr||tkr|d7}qyW|}
x0|
t|kr||
tkr|
d7}
qW|
d8}
n||d d}|
d7}
x0|
t|kr=||
tkr=|
d7}
qW||
}||7}qW|d7}qW|d7}qW|d S(	sWrap and fill the text to the specified column.

    Wrapping is always in effect, although if it is not possible to wrap a
    line (because some word is longer than `column' characters) the line is
    broken at the next available whitespace boundary.  Paragraphs are also
    always filled, unless honor_leading_ws is true and the line begins with
    whitespace.  This is the algorithm that the Python FAQ wizard uses, and
    seems like a good compromise.

    R
s

iit is
i(	RtsplitRtNLtappendRR!trstripR(ttexttcolumnthonor_leading_wstwrappedtparastparatlinestfillprevtlinetfillthistbolteol((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pytwrapsX

	


		%%

%
cCs"d}d}|j|j|S(Ns
 .
s
.
(RR+(R/tJOINERtSEP((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pytQuotePeriodsscCsnd}d}|j}|jd}|dkr=|dfS|| }||d}|jd}||fS(Nt@iR(tNonetlowertfindR+(temailtusertdomaintat_signtrest((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pyt
ParseEmails

cCs=|jd}|dkr|S|| d||djS(s3returns the address with the domain part lowercasedR?ii(RBRA(taddrtatind((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pytLCDomainss"[][()<>|:;^,\\"\000-\037\177-\377]s	[-a-z0-9]c	Cs8t|tst|trFt|dkr9d}qF|d}n|sb|jddkrntjntj|rtj	|nt
|\}}|stj|nt|dkrtj|nx]|D]U}t|dks!|ddks!ttjd|dkrtj	|qqWdS(s0Verify that an email address isn't grossly evil.iR
iR*it-N(
t
isinstancetlistttupleRtcountRtMMBadEmailErrort	_badcharstsearchtMMHostileAddressRHt
_valid_domainR(tsRDtdomain_partstp((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pyt
ValidateEmails 	

@s[^\x21-\x7e]t	PATH_INFOcCsZtjj|}|rVtjjdtjjdtjjdd}tj|rtj|d}tddt|ng|jdD]}|r|^q}tj	dkrtj	}n=t
}|rtg|D]}t|^q}nd	}|rRt|d|krRtd
d|d||d| d|d<n|SdS(
NRRRsunidentified originiterrors;Warning: Possible malformed path attack domain=%s remote=%st/iRs(Hostile listname: listname=%s: remote=%ss...(RRRtCRNLpatRSR+Rt
get_domainRtMAX_LISTNAME_LENGTHR)tmaxRR@(tenvarRR#RXtpiecestlongestt	lst_namestx((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pyt
GetPathPiecess2
(	(cCstjjdS(NtREQUEST_METHOD(RRR(((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pytGetRequestMethod:scCstjjd}tjjddk	oEtjjdjdk}|dkrtjt}|ddkr|d}qn|r|jdr|j	ddd}ntjjd	}|dkrtjjd
dtjjdd}nt
j
|d
}|r|r|dkrS|dkrS|dkrS|dkrSt}nd|}tjjd}|r||}qn|r|j|r|t|}|j
d}	|	dkr|jdd|	}
n|jd}
d|
|}n
||}|tjS(starget - scriptname only, nothing extra
    web_page_url - the list's configvar of the same name
    absolute - a flag which if set, generates an absolute url
    force_vhost - a flag which if set, prevents cpanel relative links from being used when called via cpsrvd
    tCPANELtREQUEST_SCHEMEthttpsiR\shttp://thttpitREQUEST_URItSCRIPT_NAMER
RZitprivatetlistinfotconfirmtoptionss	/3rdpartytcp_security_tokent?is../N(RRRR@RARtDEFAULT_URL_PATTERNR^t
startswithtreplaceturlparseRRRBRPtCGIEXT(ttargettweb_page_urltabsolutetforce_vhostt	is_cpaneltis_apache_httpstfullpathtbaseurlRstiRPR((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pyt	ScriptURL?s:6
0	

cCs|j}t|\}}|g}|r}|d}xCt|dkry|jd|tj|f|d}q:Wn|S(sreturns a sorted list of addresses that could possibly match
    a given name.

    For Example, given scott@pobox.com, return ['scott@pobox.com'],
    given scott@blackbox.pobox.com return ['scott@blackbox.pobox.com',
                                           'scott@pobox.com']iis%s@%s(RARHRR-tDOTR(tnameRDREtres((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pytGetPossibleMatchingAddrshs	
 cCsOi}|r0x<|D]}t||j<qWnx|D]}t||<q7W|S(s<Return a dict keyed by the entries in the list passed to it.(R!RA(tLtfoldcasetdR((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pyt	List2Dict|s

tateRtotutbtcRtftgthtktmtnRXtrRVtttvtwRetzcCsJg}x0t|d|kr8|jtjtq	Wtj|| S(Ni(RR-trandomtchoicet
_syllablestEMPTYSTRINGR(tlengthtsyls((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pytUserFriendly_MakeRandomPasswordscCsGd}g}d}zx||krytj||}Wnttfk
r|dkrytjdtj}Wqtk
r}|jtj	krnt
ddt|SXntj|||}nX|j
||t|7}qWtjtj|}|jdd| SWd|dk	rBtj|nXdS(Nis/dev/urandomR[s+urandom not available, passwords not secures
R
(R@RturandomtAttributeErrortNotImplementedErrortopentO_RDONLYtOSErrorterrnotENOENTRRtreadR-Rtbase64tencodestringRRRwtclose(Rt	bytesreadtbytestfdtnewbytesRRV((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pytSecure_MakeRandomPasswords0
cCstjrt|St|S(N(RtUSER_FRIENDLY_PASSWORDSRR(R((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pytMakeRandomPasswords	
cCsRttjd}ttjd}d}dtt|||fS(Ni4cSsVd|kodknr)|d7}nd|ko@dknrR|d7}n|S(NiiiAi4iG((R((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pytmkletters


s%c%c(tintRROtmap(tchr1tchr2R((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pyt
GetRandomSeeds	cCsy|rtj}n	tj}tjd}z:t|d}|jt|jd|j	Wdtj|XdS(NiRs
(
RtSITE_PW_FILEtLISTCREATOR_PW_FILERtumaskRtwritetsha_newt	hexdigestR(tpwt	siteadmintfilenametomasktfp((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pytset_global_passwords	cCsx|rtj}n	tj}y*t|}|jd }|jWn,tk
rs}|jtjkrondSX|S(Ni(
RRRRRRtIOErrorRRR@(RRRt	challengeR((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pytget_global_passwords	cCs2t|}|dkrdS|t|jkS(N(RR@RR(tresponseRR((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pytcheck_global_passwordss&amp;((?:#[0-9]+|[a-z]+);)cCst|tst|trFt|dkr9d}qF|d}ntjrt|trx-tjD]}|j|tj|}qhWqn|rt	j
|dtStj
dt	j
|dtSdS(NiR
itquotes&\1(RMRNRORRtBROKEN_BROWSER_WORKAROUNDtstrtBROKEN_BROWSER_REPLACEMENTSRwtcgitescapeR!t_ampreR(RVtdoubleescapeR((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pytwebsafes	
	#cCsa|jdd}t|dkrWy|dt|dfSWqWtk
rSqWXn|dfS(Nt:iiiiw(R+RRt
ValueError(RVtparts((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pyt	nntpsplits
cCs*|r|jddS|jddSdS(sMake email address unrecognizable to web spiders, but invertable.

    When for_text option is set (not default), make a sentence fragment
    instead of a token.R?s at s--at--N(Rw(RItfor_text((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pytObscureEmailscCs|jddS(s!Invert ObscureEmail() conversion.s--at--R?(Rw(RI((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pytUnobscureEmail&st	OuterExitcBseZRS((t__name__t
__module__(((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pyR.scCsg}|dk	r"|j|n|dk	rA|j|jn|jtjg}|dk	r|j|j|jtjjtj	|j
n|jtjjtj	d|jtj	d}yx|D]y}xp|D]h}tjj|||}	yt|	}tWqt
k
rN}
|
jtjkrEnd}qXqWqWWntk
rknX|dkry+tjjtj	d|}	t|	}Wqt
k
r}
|
jtjkrnt
tjd|qXn|j}|j|}|dk	ryqt|}
y|
j|}WnKtk
rt|t|d}|
jt||
j|}nXWqttfk
r}
tdd|	|
qXn|r||	fSt||	fS(NtsitetensNo template file foundRwR[sbroken template: %s
%s(R@R-tpreferred_languageRtDEFAULT_SERVER_LANGUAGERRRRtTEMPLATE_DIRt	host_nameRRRRRRRR
tinterpolatetUnicodeErrortunicodet
GetCharSettdecodedictfromt	TypeErrorRRR;(ttemplatefiletdicttrawtlangtmlistt	languagest
searchdirsRtdirRRttemplateR/tsdictt	utemplate((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pytfindtext1sh4%






cCst|||||dS(Ni(R(RRRRR((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pytmaketextsRqthelptinfotlistsRritpasswordtremoveitsett	subscribetunsubscribetwhocCsd}g}xctjj|D]O}|dkr5Pn|jrN|d7}n|tjkratS|j|qWtj	|}t
j|jjrt
S|d }t|jdd}|j|x|D]}|jsqng|jD]}|j^q}t
j|dd\}	}
|	dkrM|
dkrMqn|	t|dkon|
knr|ddkr|ddkrqnt
SqWtS(
Nis-- iitsubjectR
Ritontoff(NN(sonsoff(RCt	Iteratorstbody_line_iteratortstripRtDEFAULT_MAIL_COMMANDS_MAX_LINESRR-R,Rt	ADMINDATAthas_keyRAR!RRR+R@R(tmsgtlinecntR5R7tbodytextt	bodylinesRtwordtwordstminargstmaxargs((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pytis_administrivias8



%& cCs{|}tjjdr(tjd}n?tjjdrgtjjdrgtjdtjd}n|rwt|S|S(sReturn the full virtual path this CGI script was invoked with.

    Newer web servers seems to supply this info in the REQUEST_URI
    environment variable -- which isn't part of the CGI/1.1 spec.
    Thus, if REQUEST_URI isn't available, we concatenate SCRIPT_NAME
    and PATH_INFO, both of which are part of CGI/1.1.

    Optional argument `fallback' (default `None') is returned if both of
    the above methods fail.

    The url will be cgi escaped to prevent cross-site scripting attacks,
    unless `escape' is set to 0.
    RmRnRZ(RRRR(tfallbackRturl((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pyt
GetRequestURIs$
cCsx|r|r|nytjdtj\}}Wn6tk
rp}|jtjkrbn|jPnX|dkry||=Wqtk
rqXn|rPqqWdS(Nii(RtwaitpidtWNOHANGRRtECHILDtcleartKeyError(tkidstfunctoncetpidtstatusR((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pytreaps"	


cCstj|dS(Ni(RtLC_DESCRIPTIONS(R((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pytGetLanguageDescrscCstj|dS(Ni(RR#(R((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pyRscCstj|dS(Ni(RR#(R((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pytGetDirectionscCstjj|S(N(RR#R(R((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pyt
IsLanguagescCstjjdtjjd}tjjd}|rd|jd|rd|t|d }ntjr|rt|jStj	rt
j
tj	dptj}|jSdS(Nt	HTTP_HOSTtSERVER_NAMEtSERVER_PORTRi(RRRtendswithRRtVIRTUAL_HOST_OVERVIEWRRAtDEFAULT_URLRxtDEFAULT_URL_HOST(thosttportthostname((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pyR^!s!		cCs[|dkr*tjjtt}n|dkrGdtj|fSdtj||fS(Ns%s@%ss%s-%s@%s(R@Rt
VIRTUAL_HOSTSRR^tMAILMAN_SITE_LIST(R0textra((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pytget_site_email2s
cCs<dttjtj|j|jf}td7a|S(Ns<mailman.%d.%d.%d.%s@%s>i(t_serialttimeRtgetpidt
internal_nameR(Rtmsgid((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pytunique_message_idCs

cCs4|dkrtjd }ntj|ddS(Niiii(i(iiiii(i(R@R6t	localtimetmktime(tdate((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pytmidnightNscCs|jddjdd}tj|}xqtdt|dD]W}||dr||ddtkrd||d	||<qFd||||<qFWtj|S(
s$Convert from %-strings to $-strings.t$s$$s%%t%iiis${t}(RwtcreR+trangeRt
IDENTCHARSRR(RVRR((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pyt	to_dollar]s&cCs|jddjdd}tj|}xtdt|dD]v}||d
k	rid||<qF||dd
k	rd||dd||d<qFd||d	d||d	<qFWtjtd
|S(s$Convert from $-strings to %-strings.R@s%%s$$R?iis%(s)siN(	RwtdreR+RCRR@RRtfilter(RVRR((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pyt
to_percentis
!"cCs_i}xRtdgtj|D]!\}}}|p=|p=d^qD]}t||<qGW|S(s?Return the set (dictionary) of identifiers found in a $-string.N(RGR@RFtfindallR!(RVRRRRR((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pytdollar_identifierswsGcCs.i}x!tj|D]}t||<qW|S(s?Return the set (dictionary) of identifiers found in a %-string.(RBRIR!(RVRR((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pytpercent_identifiersscsDgtjd|}fd}fd}xtr0j||jd|sePn|jd}|jdry|t|dWq-tk
rj|d|dq-Xq9tj	j
|d	}|jdr|jdr|t|dd
!q9j||q9Wtj
}|S(Ns&(?P<ref>[^;]+);csjt|dS(N(R-tunichr(R(tnewparts(s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pytappchrscsYt|tr|Sdkr(d}n!t}|dkrId}nt||dS(Ns
iso-8859-1sus-asciiRw(RMRR@R(RVtcharset(R(s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pyt	tounicodes		it#it&t;Rti(RR+R!R-tpopRvRRthtmlentitydefst
entitydefsRR*RR(RVRRRNRPtrefRtnewstr((RRMs3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pytcanonstrs(	
"cCs|dkrd}n|dkr*d}nt|}y3t|trU|j|St||}|SWntk
rt|SXdS(Nusus-ascii(R@RRMRtencodeRRtuquote(RVRROR((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pyt
uncanonstrs		

cCscg}xG|D]?}t|}|dkr?|jd|q
|j|q
Wttj|S(Nis&#%3d;(tordR-RRR(RVRRR((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pyR[s
cCsyStjjtjj|}|j}tj|j}|j|dSWn-t	t
ttfk
rt
j|jSXdS(NRw(RCtHeadertmake_headert
decode_headert__unicode__tUEMPTYSTRINGRt
splitlinesRZtLookupErrorRRRR(RVtcsetRtustrR7((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pytonelinescCst|ts|Sd}d}t}t}t}x|t|kr||}|r|tkro|d7}n#|tkr|d7}n
||7}t}nG|r|tkrt}qn)|dkr|rt}n
|dkr|rt}||7}t}n|dkr&|r&t}||7}ntjd|r|r|tkrW|d7}q}|tkrp|d7}q}||7}qnb|d	kr|r||7}t}n<|tkr|d7}n#|tkr|d7}n
||7}|d
7}q4W|S(NR
is\ns\rRQt[t]s\ss\i(	RMRRRR,tCRR!RRS(tpatternt
newpatternRtinclasst	skiptoeoltcopynextR((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pytstrip_verbose_patternsZ



		
	



	


s<i?frames2<link(?! rel="SHORTCUT ICON" href="<mm-favicon>">)s<metas<objects<scripts
@keyframess\bj(?:ava)?script\bs\bvbs(?:cript)?\bs\bdomactivate\bs\bdomattrmodified\bs\bdomcharacterdatamodified\bs\bdomfocus(?:in|out)\bs\bdommenuitem(?:in)?active\bs\bdommousescroll\bs$\bdomnodeinserted(?:intodocument)?\bs#\bdomnoderemoved(?:fromdocument)?\bs\bdomsubtreemodified\bs
\bfscommand\bs\bonabort\bs\bon(?:de)?activate\bs\bon(?:after|before)print\bs\bon(?:after|before)update\bs+\b(?:on)?animation(?:end|iteration|start)\bs8\bonbefore(?:(?:de)?activate|copy|cut|editfocus|paste)\bs\bonbeforeunload\bs\bonbegin\bs
\bonblur\bs\bonbounce\bs\bonbroadcast\bs\boncanplay(?:through)?\bs\bon(?:cell)?change\bs\boncheckboxstatechange\bs\bon(?:dbl)?click\bs\bonclose\bs\boncommand(?:update)?\bs\boncomposition(?:end|start)\bs\boncontextmenu\bs\boncontrolselect\bs
\boncopy\bs	\boncut\bs\bondataavailable\bs!\bondataset(?:changed|complete)\bs5\bondrag(?:drop|end|enter|exit|gesture|leave|over)?\bs\bondragstart\bs
\bondrop\bs\bondurationchange\bs
\bonemptied\bs\bonend(?:ed)?\bs\bonerror(?:update)?\bs\bonfilterchange\bs\bonfinish\bs\bonfocus(?:in|out)?\bs\bonhashchange\bs
\bonhelp\bs\boninput\bs\bonkey(?:up|down|press)\bs\bonlayoutcomplete\bs\bon(?:un)?load\bs\bonloaded(?:meta)?data\bs\bonloadstart\bs\bonlosecapture\bs\bonmedia(?:complete|error)\bs
\bonmessage\bs6\bonmouse(?:down|enter|leave|move|out|over|up|wheel)\bs\bonmove(?:end|start)?\bs\bon(?:off|on)line\bs
\bonopen\bs\bonoutofsync\bs\bonoverflow(?:changed)?\bs\bonpage(?:hide|show)\bs\bonpaint\bs\bonpaste\bs\bonpause\bs\bonplay(?:ing)?\bs\bonpopstate\bs*\bonpopup(?:hidden|hiding|showing|shown)\bs\bonprogress\bs\bonpropertychange\bs\bonradiostatechange\bs\bonratechange\bs\bonreadystatechange\bs\bonrepeat\bs\bonreset\bs\bonresize(?:end|start)?\bs\bonresume\bs
\bonreverse\bs'\bonrow(?:delete|enter|exit|inserted)\bs#\bonrows(?:delete|enter|inserted)\bs\bonscroll\bs\bonsearch\bs\bonseek(?:ed|ing)?\bs\bonselect(?:start)?\bs\bonselectionchange\bs
\bonshow\bs\bonstart\bs
\bonstalled\bs
\bonstop\bs
\bonstorage\bs\bonsubmit\bs
\bonsuspend\bs\bonsync(?:from|to)preference\bs\bonsyncrestored\bs
\bontext\bs\bontime(?:error|update)\bs\bontoggle\bs$\bontouch(?:cancel|end|move|start)\bs\bontrackchange\bs\b(?:on)?transitionend\bs\bonunderflow\bs
\bonurlflip\bs\bonvolumechange\bs
\bonwaiting\bs\bonwheel\bs\bseeksegmenttime\bs\bsvgabort\bs\bsvgerror\bs\bsvgload\bs
\bsvgresize\bs
\bsvgscroll\bs
\bsvgunload\bs\bsvgzoom\bt|s
[-	--]s,(&#[0-9]+;?)|(&#x[0-9a-f]+;?)|(%[0-9a-f]{2})cCs|jjjd}yG|jds<|jdrRt|dd}nt|d}Wntk
rvdSX|dkrt|SdSd	S(
s=Translate &#... and %xx encodings into the encoded character.s&#;ReR@iii
R
iN(tgroupRARRvRRtchr(tmotmatchtval((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pyt
_translates

cCs3tjtjdtjt|r+tStSdS(sWCheck HTML string for various tags, script language names and
    'onxxx' actions that can be used in XSS attacks.
    Currently, this a very simple minded test.  It just looks for
    patterns without analyzing context.  Thus, it potentially flags lots
    of benign stuff.
    Returns True if anything suspicious found, False otherwise.
    R
N(t_badhtmlRSt_filtercharsRt
_encodedcharsRwR!R(thtml((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pytsuspiciousHTMLs	cCs:tr
dS|sdSytj|}Wn*tjk
rS}tdd||dSXx|jD]}|jsa|jdsa|jdrqantj	dd|j}|sqan|j
jd}|d	jd
r	t}|d	dg|d}nt
}|jdj|}|t|<qaWdS(s\This loads and parses the data from the url argument into s_dict for
    use by get_org_dom.NR[s#Unable to retrieve data from %s: %sR*s//s .*R
Rit!i(ts_dictturllib2turlopentURLErrorRt	readlinesRRvRRRAR+R!RtreverseR(RRRR7RtexcR((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pytget_suffixess2
+
cCs4|t|dt| }|jdj|S(sJA helper to get a domain name consisting of the first l+1 labels
    in d.iR(tminRRR(Rtltdom((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pyt_get_doms
cCststtjng}|jjd}|jxtjD]}|jd}t|t|krHxt	t|dD].}||||kr||dkrPqqW|t|d|dks|ddkr|j
|qqHqHW|st|dSd}xk|D]c}t|rSt|t|jddSt|jd|kr#t|jd}q#q#Wt||S(sqGiven a domain name, this returns the corresponding Organizational
    Domain which may be the same as the input.Rit*ii(R~RRt$DMARC_ORGANIZATIONAL_DOMAIN_DATA_URLRAR+RtkeysRRCR-R(REthitsRRtksRR((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pytget_org_doms,
$.


 cCststdd|jtS|j}|jd}|dkrHtS||d}t||d|}|dkr||St|}||krt||d|dt}|dkr|SntS(NR[s@DNS lookup for dmarc_moderation_action for list %s not availableR?is_dmarc.tcontinuetorg(	tdns_resolverRt	real_nameRRAtrfindt_DMARCProhibitedRR!(RRCRFtf_domReto_dom((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pytIsDMARCProhibiteds&
cCs
yOtjj}ttj|_ttj|_|j	|tj
j}Wnztjjtjj
fk
rudStjjk
rtdd||tStk
r}tdd|||jtSXi}i}t|dg}	x|jjD]}
|
jjj}|
jtj
jkrE|
jdjj||<n|
jtj
jkr`qn|j|gjdj|
jdj qWt!|	}t|}
x~|r(|j"d}||kr|||
krqn|j|||
j#|||	j#|||	j$|qqWt%|	dkrNtdd	|nx|	D]}||krmqUnt&d
||}t%|dkrdSt%|dkrtdd|t%|t'Sx:|D]2}t(j)d|t(j*}|r|r|j+dj}n9t(j)d
|t(j*}|r|j+dj}nq|dkrytdd|j,||||tS|j-r|dkrtdd|j,||||tS|j.r|j-r|j/dkr|dkrtdd|j,||||tSqWqUWt'S(NRR[s2DNSException: No Nameservers available for %s (%s)s:DNSException: Unable to query DMARC policy for %s (%s). %sRiR
isYmultiple DMARC entries in results for %s,
                   processing each to be strictcSs
|jdS(Ns	v=DMARC1;(Rv(R((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pyt<lambda>pssfRRset of TXT records for %s has %d v=DMARC1 entries;
                       ignoring them per RFC 7849s\bsp=(\w*)\bs\bp=(\w*)\btrejecttvettes6%s: DMARC lookup for %s (%s) found p=reject in %s = %st
quarantines:%s: DMARC lookup for %s (%s) found p=quarantine in %s = %sitnones4%s: DMARC lookup for %s (%s) found p=none in %s = %s(ii(0tdnstresolvertResolvertfloatRtDMARC_RESOLVER_TIMEOUTttimeouttDMARC_RESOLVER_LIFETIMEtlifetimetqueryt	rdatatypetTXTtNXDOMAINtNoAnswert
NoNameserversRR!Rt__doc__RRtanswerRtto_textRAtrdtypetCNAMEtitemsRzt
setdefaultR-RtstringsRNRTtaddtdiscardRRGRRRSt
IGNORECASERrRt"dmarc_quarantine_moderation_actiontdmarc_none_moderation_actiontdmarc_moderation_action(RRCtdmarc_domainRRttxt_recsRtresults_by_nametcnamest
want_namesttxt_recRtexpandstseentitemtdmarcstentryRttpolicy((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pyR3s
	

	

			cCsv|jdkrtS|j}tj}tj|gj|t|jt	t
t|}|jx0|D](}t|||krxt||=qxqxWtd7att
jkrDdax~tjD]m}t	t
t|}|jx0|D](}t|||krt||=qqWt|st|=qqWn|j|sWtSt
tj|g|jkS(s;For lists that request it, we keep track of recent posts by address.
A message from an address to a list, if the list requests it, is remembered
for a specified time whether or not the address is a list member, and if the
address is a member and the member is over the threshold for the list, that
fact is returned.ii(tmember_verbosity_thresholdRRAR6trecentMemberPostingsRR-Rtmember_verbosity_intervalRCRRtclean_countRtVERBOSE_CLEAN_LIMITRtisMemberR(RRCtnowReRRI((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pytIsVerboseMembers4	





cCs|s
gSy|jdd\}}Wntk
r:gSX|j}tjdd|j}|jd}g}x$|D]}|j|jdq~WxE|D]=}||krg|D] }||kr|d|^qSqWgS(sUThe arguments are an email address and a string representing a
    list of lists in a form like 'a,b,c;1,2' representing [['a', 'b',
    'c'],['1', '2']].  The inner lists are domains which are
    equivalent in some sense.  The return is an empty list or a list
    of email addresses equivalent to the first argument.
    For example, given

    email = 'user@me.com'
    domains_list = '''domain1, domain2; mac.com, me.com, icloud.com;
                   domaina, domainb
                   '''

    check_eq_domains(email, domains_list) will return
    ['user@mac.com', 'user@icloud.com']
    R?is\sR
RSt,(trsplitRRARRR+R-(RCtdomains_listtlocalREtdomainsRRe((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pytcheck_eq_domainss 


/cCsy}|jdd dkr9tt|jddS|jdd jdkrxtt|jdddSdSWntk
rdSXdS(NiRQRiu�(RrRLRRAR(Rt((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pyt_invert_xmls 
cCsWt|trO|j|d}tjdt|}tjdt|}|S|SdS(skThis converts a string s, encoded in cset to a unicode with translation
    of XML character references and textual \uxxxx escapes.  It is more or less
    the inverse of unicode.decode(cset, errors='xmlcharrefreplace').  It is
    similar to canonstr above except for replacing invalid refs with the
    unicode replace character and recognizing \u escapes.
    Rwu&(#[0-9]+);u(?i)\\(u[a-f0-9]{4})N(RMRtdecodeRRR(RVRetus((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pytxml_to_unicodescCsAts
tStr{y.t|dddd}tj|j}Wntk
rRtSXdjdj	|j
dd }nM|j
d}t|dkrtSd	j|d
|d|d|d
}tj
j}y|j|tjj}Wntk
rtSX|stS|jj}tjd|tjr=tStS(Ntencodingsus-asciiterrorsRws{0}.zen.spamhaus.orgRiis {0}.{1}.{2}.{3}.zen.spamhaus.orgiiiis127\.0\.0\.[2-7]$(RRthave_ipaddressRt	ipaddresst
ip_addresstreverse_pointerRtformatRR+RRRRRRtARtrrsetRRRSt	MULTILINER!(tiptuiptptrtlookupRRtansR/((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pyt	banned_ips6
(


cCsts
tS|j}t|\}}d|}tjj}y|j|tjj	}Wnt
k
rqtSX|s|tS|jj}t
jd|t
jrt
jd|t
jstSntS(Ns%s.dbl.spamhaus.orgs127\.0\.1\.\d{1,3}$s127\.0\.1\.255$(RRRARHRRRRRRRRRRRSRR!(RCRDRERRRR/((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pyt
banned_domain*s"

cCsx||krd}n||}tjt|}||d}|jddd}t|||dt|fS(sgReturns a CAPTCHA question, the HTML for the answer box, and
    the data to be put into the CSRF tokenRitcaptcha_answertsizeiRL(Rt	randrangeRt	FormatBoxRR(RRtcaptchastidxtquestiontbox_html((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pytcaptcha_displayAs	
cCsy%|jd\}}t|}Wntk
r9tSX||krJtS||}|tt|krptS||dd}tj||S(NRLiR?(R+RRRRCRRRu(Rtgiven_answerRRtcorrect_answer_pattern((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pytcaptcha_verifyNs

(RRRRR(RRRRRRRRRRXRRVRRRReR(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(Rt
__future__RRtsysRRR6RRRRRxRUtemail.HeaderRCtemail.Iteratorstemail.ErrorsRttypesRtstringRRRtImportErrort_lowertuppertMailmanRRR	tMailman.SafeDictR
tMailman.Logging.SyslogRthashlibtmd5tmd5_newtsha1RtshatnewR!Rt	NameErrortdns.resolverRt
dns.exceptionRRRRRRbRjR,RRDtcompileRRBRFR'R)R;R>RHRKRRRURYR]RfRhR@RRRt_vowelst_consonantsRRRR-RRtMEMBER_PASSWORD_LENGTHRRRRRRRRRRt	ExceptionRRRR
RRR"R$RR%R&R^R4R5R:R>RERHRJRKRYR\R[RgRpt	_badwordsRRxRyRzRwR|R~RRRRRRRRRRRRRRR(((s3/usr/local/cpanel/3rdparty/mailman/Mailman/Utils.pyt<module>s&
	

	








		K		
			"	)	


		!		
	s
	'										/			@							 	l	*	"					
Back to Directory File Manager