o
    ô<âg*
  ã                   @   s8   d dl Z d dlZd dlmZ ddd„ZG dd„ dƒZdS )	é    N)ÚSuspiciousFileOperationFc                 C   sx   t j | ¡dv rtd|  ƒ‚|r,t t| ƒ dd¡¡}| ¡ s$d|j	v r*td|  ƒ‚| S | t j | ¡kr:td|  ƒ‚| S )N>   Ú Ú.ú..z$Could not derive file name from '%s'ú\ú/r   z'Detected path traversal attempt in '%s'z%File name '%s' includes path elements)
ÚosÚpathÚbasenamer   ÚpathlibÚPurePosixPathÚstrÚreplaceÚis_absoluteÚparts)ÚnameÚallow_relative_pathr	   © r   úJ/var/www/html/venv/lib/python3.10/site-packages/django/core/files/utils.pyÚvalidate_file_name   s   ÿýr   c                   @   sä   e Zd ZdZedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZ	edd„ ƒZ
ed	d„ ƒZed
d„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZdd„ Zdd„ Zdd„ Zdd„ ZdS )ÚFileProxyMixinzû
    A mixin class used to forward file methods to an underlying file
    object.  The internal file object has to be called "file"::

        class FileProxy(FileProxyMixin):
            def __init__(self, file):
                self.file = file
    c                 C   ó   | j jS ©N)ÚfileÚencoding©Úselfr   r   r   Ú<lambda>$   ó    zFileProxyMixin.<lambda>c                 C   r   r   )r   Úfilenor   r   r   r   r   %   r   c                 C   r   r   )r   Úflushr   r   r   r   r   &   r   c                 C   r   r   )r   Úisattyr   r   r   r   r   '   r   c                 C   r   r   )r   Únewlinesr   r   r   r   r   (   r   c                 C   r   r   )r   Úreadr   r   r   r   r   )   r   c                 C   r   r   )r   Úreadintor   r   r   r   r   *   r   c                 C   r   r   )r   Úreadliner   r   r   r   r   +   r   c                 C   r   r   )r   Ú	readlinesr   r   r   r   r   ,   r   c                 C   r   r   )r   Úseekr   r   r   r   r   -   r   c                 C   r   r   )r   Útellr   r   r   r   r   .   r   c                 C   r   r   )r   Útruncater   r   r   r   r   /   r   c                 C   r   r   )r   Úwriter   r   r   r   r   0   r   c                 C   r   r   )r   Ú
writelinesr   r   r   r   r   1   r   c                 C   s   | j  p| j jS r   )r   Úclosedr   r   r   r   r,   3   s   zFileProxyMixin.closedc                 C   ó$   | j rdS t| jdƒr| j ¡ S dS )NFÚreadableT)r,   Úhasattrr   r.   r   r   r   r   r.   7   ó
   
zFileProxyMixin.readablec                 C   s2   | j rdS t| jdƒr| j ¡ S dt| jddƒv S )NFÚwritableÚwÚmoder   )r,   r/   r   r1   Úgetattrr   r   r   r   r1   >   s
   
zFileProxyMixin.writablec                 C   r-   )NFÚseekableT)r,   r/   r   r5   r   r   r   r   r5   E   r0   zFileProxyMixin.seekablec                 C   s
   t | jƒS r   )Úiterr   r   r   r   r   Ú__iter__L   s   
zFileProxyMixin.__iter__N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úpropertyr   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r.   r1   r5   r7   r   r   r   r   r      s,    	
r   )F)r   r   Údjango.core.exceptionsr   r   r   r   r   r   r   Ú<module>   s
    
