HEX
Server: LiteSpeed
System: Linux shams.tasjeel.ae 5.14.0-611.5.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Nov 11 08:09:09 EST 2025 x86_64
User: infowars (1469)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: //usr/lib64/python3.9/site-packages/__pycache__/ldif.cpython-39.pyc
a

�.d'O�@sLdZdZgd�ZddlZddlmZmZddlmZddl	Z	ddl
mZddlm
Z
d	Zd
ZedeZeded
Zeded
Ze�de�Zde�Zddddd�Zddddd�Zgd�ZiZeD]Zdee<q�dd�ZdZe�e�Zdd�ZGd d!�d!�Z d-d#d$�Z!Gd%d&�d&�Z"Gd'd(�d(e"�Z#Gd)d*�d*e"�Z$d.d+d,�Z%dS)/zc
ldif - generate and parse LDIF data (see RFC 2849)

See https://www.python-ldap.org/ for details.
z3.4.3)�ldif_pattern�
CreateLDIF�	ParseLDIF�
LDIFWriter�
LDIFParser�LDIFRecordList�LDIFCopy�N)�	b64encode�	b64decode)�StringIO)�urlparse)�urlopenz[\w;.-]+(;[\w_-]+)*z(([^,]|\\,)+|".*?")z	[ ]*=[ ]*z([ ]*\+[ ]*z)*[ ]*z
([ ]*,[ ]*z^%s$z>^((dn(:|::) %(dn_pattern)s)|(%(attrtype_pattern)s(:|::) .*)$)+���)�add�delete�replace�	incrementrrrr)rrrr)rr�modifyZmodrdncCs,|dkrdSt�|�}|dko*|�d�|kS)z!
  returns 1 if s is a LDAP DN
  �rNr)�dn_regex�match�group)�sZrm�r�*/usr/lib64/python3.9/site-packages/ldif.py�is_dn6s
rs (^(|
|
| |:|<)|[

�-�]+|[ ]+$)cCsdd�|D�S)zN
  return a dictionary with all items of l being the keys of the dictionary
  cSsi|]
}|d�qS�Nr)�.0�irrr�
<dictcomp>G�zlist_dict.<locals>.<dictcomp>r)�lrrr�	list_dictCsr$c@sJeZdZdZddd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dS)rz�
  Write LDIF entry or change records to file object
  Copy LDIF input to a file output object containing all data retrieved
  via URLs
  N�L�
cCs4||_tdd�|pgD��|_||_||_d|_dS)aB
    output_file
        file object for output; should be opened in *text* mode
    base64_attrs
        list of attribute types to be base64-encoded in any case
    cols
        Specifies how many columns a line may have before it's
        folded into many lines.
    line_sep
        String used as line separator
    cSsg|]}|���qSr��lower�r�arrr�
<listcomp>^r"z'LDIFWriter.__init__.<locals>.<listcomp>rN)�_output_filer$�
_base64_attrs�_cols�_last_line_sep�records_written)�self�output_file�base64_attrs�cols�line_seprrr�__init__Qs
zLDIFWriter.__init__cCs�t|�}||jkr.|j�|�|j�|j�n�|j}|j�|dt||j���|j�|j�||kr�|j�d�|j�||t|||jd���|j�|j�||jd}q^dS)z7
    Write string line as one or more folded lines
    r� rN)�lenr.r,�writer/�min)r1�line�line_len�posrrr�
_unfold_linescs
$zLDIFWriter._unfold_linescCs|��|jvpt�|�duS)z�
    returns 1 if attr_value has to be base-64 encoded because
    of special chars or because attr_type is in self._base64_attrs
    N)r(r-�safe_string_re�search)r1�	attr_type�
attr_valuerrr�_needs_base64_encodingxs�z!LDIFWriter._needs_base64_encodingcCsZ|�||�r<t|��d�}|�dd�}|�d�||g��n|�d�||�d�g��dS)z�
    Write a single attribute type/value pair

    attr_type
          attribute type (text)
    attr_value
          attribute value (bytes)
    �asciir&rz:: �: N)rCr	�decoderr>�join)r1rArBZencodedrrr�_unparseAttrTypeandValue�s	z#LDIFWriter._unparseAttrTypeandValuecCs0t|���D]\}}|D]}|�||�qqdS)z3
    entry
        dictionary holding an entry
    N)�sorted�itemsrH)r1�entryrA�valuesrBrrr�_unparseEntryRecord�szLDIFWriter._unparseEntryRecordc	Cs�t|d�}|dkrd}n|dkr(d}ntd|��|�d|�d��|D]|}|dkr`|\}}n2|dkr�|\}}}|�t||�d��ntd	��|r�|D]}|�||�q�|dkrJ|j�d
|j�qJdS)zP
    modlist
        list of additions (2-tuple) or modifications (3-tuple)
    rrrrrz modlist item of wrong length: %d�
changetyperDz'Subsequent modlist item of wrong length�-N)r8�
ValueErrorrH�encode�
MOD_OP_STRr,r9r/)	r1ZmodlistZmod_lenrN�mod�mod_typeZmod_valsZmod_opZmod_valrrr�_unparseChangeRecord�s*


�zLDIFWriter._unparseChangeRecordcCsp|�d�}|�d|�t|t�r,|�|�n&t|t�rB|�|�ntdt|���|j	�
|j�|jd|_dS)z�
    dn
          string-representation of distinguished name
    record
          Either a dictionary holding the LDAP entry {attrtype:record}
          or a list with a modify list like for LDAPObject.modify().
    �utf-8�dnz8Argument record must be dictionary or list instead of %srN)
rQrH�
isinstance�dictrM�listrUrP�reprr,r9r/r0)r1rW�recordrrr�unparse�s	


zLDIFWriter.unparse)Nr%r&)�__name__�
__module__�__qualname__�__doc__r6r>rCrHrMrUr]rrrrrJs
	rr%cCsDtjdtdd�t�}t|||d�}|�||�|��}|��|S)a�
  Create LDIF single formatted record including trailing empty line.
  This is a compatibility function.

  dn
        string-representation of distinguished name
  record
        Either a dictionary holding the LDAP entry {attrtype:record}
        or a list with a modify list like for LDAPObject.modify().
  base64_attrs
        list of attribute types to be base64-encoded in any case
  cols
        Specifies how many columns a line may have before it's
        folded into many lines.
  zhldif.CreateLDIF() is deprecated. Use LDIFWriter.unparse() instead. It will be removed in python-ldap 3.1r��category�
stacklevelr&)�warnings�warn�DeprecationWarningrrr]�getvalue�close)rWr\r3r4�fZldif_writerrrrrr�s�rc@sdeZdZdZddd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dd�Zddd�Zdd�Z
dS)rz�
  Base class for a LDIF parser. Applications should sub-class this
  class and override method handle() to implement something meaningful.

  Public class attributes:

  records_read
        Counter for records processed so far
  Nrr&cCs�||_t|j�d�t�|_||_tdd�|p.gD��|_tdd�|pFgD��|_||_	d|_
d|_d|_d|_
i�td�|_t|_z|��|_Wnty�d|_Yn0dS)a
    Parameters:
    input_file
        File-object to read the LDIF input from
    ignored_attr_types
        Attributes with these attribute type names will be ignored.
    max_entries
        If non-zero specifies the maximum number of entries to be
        read from f.
    process_url_schemes
        List containing strings with URLs schemes to process with urllib.
        An empty list turns off all URL processing and the attribute
        is ignored completely.
    line_sep
        String used as line separator
    rcSsg|]}|���qSrr')rrrrrr+r"z'LDIFParser.__init__.<locals>.<listcomp>cSsg|]}|���qSrr'r)rrrr+r"Nr)�_input_filerX�read�bytes�_file_sends_bytes�_max_entriesr$�_process_url_schemes�_ignored_attr_typesr/�version�line_counter�byte_counter�records_read�fromkeys�CHANGE_TYPES�changetype_counterr
�
_b64decode�	_readline�
_last_line�EOFError)r1�
input_file�ignored_attr_types�max_entries�process_url_schemesr5rrrr6�s zLDIFParser.__init__cCsdS)zw
    Process a single content LDIF record. This method should be
    implemented by applications using LDIFParser.
    Nr�r1rWrKrrr�handle&szLDIFParser.handlecCs~|j��}|jr|�d�}|jd|_|jt|�|_|s>dS|dd�dkrZ|dd�S|dd�dkrv|dd�S|SdS)NrVr���z
���r&)rk�readlinernrFrsrtr8)r1rrrrrz-s

zLDIFParser._readlinecCsj|jdurtd|j|jf��|jg}|��}|rZ|ddkrZ|�|dd��|��}q.||_d�|�S)zG
    Unfold several folded lines with trailing space into one line
    Nz%EOF reached after %d lines (%d bytes)rr7rr)r{r|rsrtrz�appendrG)r1Zunfolded_linesZ	next_linerrrr>>s
�
zLDIFParser._unfold_linesc	
CsZ|��}|r"|ddkr"|��}q|s*dS|dkr6dSz|�d�}Wn4tyx}ztdt|���WYd}~n
d}~00|d|�}|||d	�}|d
kr�||d	d���}|�d�}n�|dkr�||d	d�}|�d
�}|�|�}nf|dk�r<||d	d���}d}|j�rRt	|�}|d|jv�rRt
|���}n||dd��d�}||fS)z�
    Parse a single attribute type and value pair from one or
    more lines of LDIF data

    Returns attr_type (text) and attr_value (bytes)
    r�#�NNrO)rON�:zno value-spec in %sNrrErVz::rDz:<r)r>�indexrPr[�lstriprQry�striprprr
rl)	r1Z
unfolded_lineZ	colon_pos�erAZ
value_specrB�url�urrr�_next_key_and_valueOs:
&

zLDIFParser._next_key_and_valuecCsT|j}z*|�\}}|dur.|dur.|�\}}qWntyJd\}}Yn0||fS)z�
    Consume empty lines until first non-empty line.
    Must only be used between full records!

    Returns non-empty key-value-tuple.
    Nr�)r�r|)r1�next_key_and_value�k�vrrr�_consume_empty_liness
zLDIFParser._consume_empty_linescCsj|j}z4|��\}}|dkr8t|�d��|_|��\}}WntyNYdS0|dk�rf|jrn|j|jk�rf|dkr�td|j	t
|�f��|�d�}t|�s�td|j	t
|�f��|}i}|�\}}|dk�r@|��|j
v�rz||�|�Wnt�y|g||<Yn0z|�\}}Wq�t�y<d\}}Yq�0q�|�||�|jd	|_|��\}}qPdS)
z8
    Continuously read and parse LDIF entry records
    rrrDNrW�;Line %d: First line of record does not start with "dn:": %srV�6Line %d: Not a valid string-representation for dn: %s.r�r)r�r��intrFrrr|rorurPrsr[rr(rqr��KeyErrorr�)r1r�r�r�rWrKrrr�parse_entry_records�sF
�
�


zLDIFParser.parse_entry_recordscCs|��S)zM
    Invokes LDIFParser.parse_entry_records() for backward compatibility
    )r�)r1rrr�parse�szLDIFParser.parsecCsgpd}dS�z�
    Process a single LDIF record representing a single modify operation.
    This method should be implemented by applications using LDIFParser.
    Nr�r1rW�modops�controlsrrr�
handle_modify�szLDIFParser.handle_modifycCs|j}|��\}}|dkr0t|�|_|��\}}|dk�r|jrN|j|jk�r|dkrltd|jt|�f��|�	d�}t
|�s�td|jt|�f��|}|�\}}g}|dk�r |dk�r |�	d�}z|�dd�\}}}Wn(t�yd}|�dd	�\}}Yn0|�|||f�|�\}}q�d}	|d
k�r`|�	d�}|t
v�rRtdt|���|}	|�\}}|	dk�r�g}
�z|dk�rnzt|}Wn*t�y�td
|jt|�f��Yn0|�	d�}|}g}
z|�\}}Wnt�y�d\}}Yn0||k�r6|
�|�z|�\}}Wnt�y0d\}}Yn0�q�|
�|||
�pFdf�|�\}}|dk�rr|�\}}�qrWnt�y�d\}}Yn0|
�r�|�||
|�n|dk�r�|�\}}�q�|��\}}z|j|	d	|j|	<Wnt�y�d	|j|	<Yn0|jd	|_q0dS)NrrrWr�rVr�Zcontrolr7rrrNzInvalid changetype: %srz"Line %d: Invalid mod-op string: %sr�rO)r�r�r�rrrorurPrsr[rFr�splitr��valid_changetype_dict�MOD_OP_INTEGERr�r|r�rx)r1r�r�r�rWr�Zcontrol_typeZcriticalityZ
control_valuerNr�ZmodopZmodattrZ	modvaluesrrr�parse_change_records�s�

�
�














zLDIFParser.parse_change_records)NrNr&)N)r^r_r`rar6r�rzr>r�r�r�r�r�r�rrrrr�s
�
-06
rc@s,eZdZdZd
dd�Zdd�Zddd	�ZdS)rz�
  Collect all records of a LDIF file. It can be a memory hog!

  Records are stored in :attr:`.all_records` as a single list
  of 2-tuples (dn, entry), after calling :meth:`.parse`.
  NrcCs"t�|||||�g|_g|_dSr)rr6�all_records�all_modify_changes)r1r}r~rr�rrrr6HszLDIFRecordList.__init__cCs|j�||f�dS)zS
    Append a single record to the list of all records (:attr:`.all_records`).
    N)r�r�r�rrrr�SszLDIFRecordList.handlecCsgpd}|j�|||f�dSr�)r�r�r�rrrr�YszLDIFRecordList.handle_modify)NrN)N)r^r_r`rar6r�r�rrrrr@s

�
rc@s"eZdZdZd
dd�Zdd	�ZdS)rzM
  Copy LDIF input to LDIF output containing all data retrieved
  via URLs
  Nrr%r&c		Cs&t�|||||�t||||�|_dS)z=
    See LDIFParser.__init__() and LDIFWriter.__init__()
    N)rr6r�_output_ldif)	r1r}r2r~rr�r3r4r5rrrr6hs	zLDIFCopy.__init__cCs|j�||�dS)z2
    Write single LDIF record to output file.
    N)r�r]r�rrrr�tszLDIFCopy.handle)NrNNr%r&)r^r_r`rar6r�rrrrrbs
�
rcCs.tjdtdd�t|||dd�}|��|jS)zL
  Parse LDIF records read from file.
  This is a compatibility function.
  zildif.ParseLDIF() is deprecated. Use LDIFRecordList.parse() instead. It will be removed in python-ldap 3.1rrbr)r~rr�)rerfrgrr�r�)rjZignore_attrsZ
maxentriesZldif_parserrrrr{s��r)Nr%)Nr)&ra�__version__�__all__�re�base64r	r
�iorre�urllib.parserZurllib.requestr
Zattrtype_patternZattrvalue_patternZattrtypeandvalue_patternZrdn_patternZ
dn_pattern�compiler�varsrr�rRrwr��crZSAFE_STRING_PATTERNr?r$rrrrrrrrrr�<module>sN
��



T"