o
    ä›eb
  ã                   @   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   sl   t j | ¡dv rtd|  ƒ‚|r&t | ¡}| ¡ sd|jv r$td|  ƒ‚| S | t j | ¡kr4t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Ú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   0   r   c                 C   r   r   )r   Úwriter   r   r   r   r   1   r   c                 C   r   r   )r   Ú
writelinesr   r   r   r   r   2   r   c                 C   s   | j  p| j jS r   )r   Úclosedr   r   r   r   r(   4   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*   8   ó
   
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   r-   Úgetattrr   r   r   r   r-   ?   s
   
zFileProxyMixin.writablec                 C   r)   )NFÚseekableT)r(   r+   r   r1   r   r   r   r   r1   F   r,   zFileProxyMixin.seekablec                 C   s
   t | jƒS r   )Úiterr   r   r   r   r   Ú__iter__M   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*   r-   r1   r3   r   r   r   r   r      s,    	
r   )F)r   r	   Údjango.core.exceptionsr   r   r   r   r   r   r   Ú<module>   s
    
