ruạṛ
a [��fN � @ s4 d dl Z d dlZd dlZd dlZG dd� de�ZdS )� Nc @ s8 e Zd ZdZe�d�ZdZddd�Zdd� Z d d � Z dS ) �StaticRouteau Represents a static route. Args: prefix (str): The path prefix to match for this route. If the path in the requested URI starts with this string, the remainder of the path will be appended to the source directory to determine the file to serve. This is done in a secure manner to prevent an attacker from requesting a file outside the specified directory. Note that static routes are matched in LIFO order, and are only attempted after checking dynamic routes and sinks. directory (str): The source directory from which to serve files. Must be an absolute path. downloadable (bool): Set to ``True`` to include a Content-Disposition header in the response. The "filename" directive is simply set to the name of the requested file. u [ --~?<>:*|'"]i Fc C sN |� d�std��tj�|�s&td��|�d�s8|d7 }|| _|| _|| _d S )N�/zprefix must start with '/'z"directory must be an absolute path) � startswith� ValueError�os�path�isabs�endswith�_prefix� _directory� _downloadable)�self�prefix� directory�downloadable� r �y/sparta/input/_build_configuration/image_build+validate/lib/bmcenv/lib64/python3.9/site-packages/falcon/routing/static.py�__init__$ s zStaticRoute.__init__c C s |� | j�S )z0Check whether the given path matches this route.)r r )r r r r r �match5 s zStaticRoute.matchc C s |j t| j�d� }|rT|�� �d�|ksT| j�|�sTd|v sTd|v sTt|�| jkr\t� � �t j �|�}|�d�s||�d�r�t� � �t j � | j|�}d|v s�|�| j�s�t� � �zt�|d�|_W n ty� t� � �Y n0 t j �|�d }|jj�|d �|_| j�rt j �|�|_dS )z"Resource responder for this route.N�.�\z//z../r z..�rb� zapplication/octet-stream)r �lenr �strip�rstrip�_DISALLOWED_CHARS_PATTERN�search�_MAX_NON_PREFIXED_LEN�falcon�HTTPNotFoundr �normpathr �joinr �io�open�stream�IOError�splitext�options�static_media_types�get�content_typer �basename�downloadable_as)r �req�resp�without_prefix� normalized� file_path�suffixr r r �__call__9 s<