Server IP : 192.158.238.246 / Your IP : 18.118.212.165 Web Server : LiteSpeed System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64 User : jenniferflocom ( 1321) PHP Version : 8.1.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /opt/alt/python37/lib/python3.7/site-packages/paste/debug/__pycache__/ |
Upload File : |
B ���]� � @ sX d Z ddlmZ ddlZddlmZ ddlZddlZdgZG dd� de �Z d dd �ZdS )z� Middleware that tests the validity of all generated HTML using the `WDG HTML Validator <http://www.htmlhelp.com/tools/validator/>`_ � )�StringION)�header_value�WDGValidateMiddlewarec @ s@ e Zd ZdZe�dej�Zd dd�Zdd� Z d d � Z dd� ZdS )r ab Middleware that checks HTML and appends messages about the validity of the HTML. Uses: http://www.htmlhelp.com/tools/validator/ -- interacts with the command line client. Use the configuration ``wdg_path`` to override the path (default: looks for ``validate`` in $PATH). To install, in your web context's __init__.py:: def urlparser_wrap(environ, start_response, app): return wdg_validate.WDGValidateMiddleware(app)( environ, start_response) Or in your configuration:: middleware.append('paste.wdg_validate.WDGValidateMiddleware') z</body>N�validatec C s || _ || _d S )N)�app�wdg_path)�selfr �global_confr � r �I/opt/alt/python37/lib/python3.7/site-packages/paste/debug/wdg_validate.py�__init__% s zWDGValidateMiddleware.__init__c s t � � g �d� ��fdd� }| �||�}zx|D ]}� �|� q0W W d t|d�rX|�� X � �� }�\}}t|d�pvd} | �d�s�| �d�s�| �d�s�|gS g } | �d �r�| �d � | � | j | |�}|�r| �||�d }|�dt t|d ��f� |�dt t|��f� |gS )Nc s �� | |f� �| ||� � jS )N)�extend�write)�status�headers�exc_info)�output�response�start_responser r �writer_start_response- s z=WDGValidateMiddleware.__call__.<locals>.writer_start_response�closezcontent-type� z text/htmlz text/xhtmlzapplication/xhtmlztext/xhtml+xmlz--xmlr zContent-Lengthzcontent-length)N)r r r �hasattrr �getvaluer � startswith�append�call_wdg_validater � add_error�remove�str�len)r �environr r Zapp_iter�s�pager r �v�ops�html_errorsr )r r r r �__call__) s8 zWDGValidateMiddleware.__call__c C sL t d krtd��t j|g| ddt jt jt jd�}|�|�d }|�� |S )Nz>This middleware requires the subprocess module from Python 2.4FT)�shell� close_fds�stdout�stdin�stderrr )� subprocess� ValueError�Popen�PIPE�STDOUT�communicate�wait)r r r% r# �procr* r r r r P s z'WDGValidateMiddleware.call_wdg_validatec C sR dt �|� }| j�|�}|rD|d |�� � | ||�� d � gS || gS d S )NzR<pre style="background-color: #ffd; color: #600; border: 1px solid #000;">%s</pre>)�cgi�escape�_end_body_regex�search�start)r Z html_pager&