HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberPanel/lib/python3.10/site-packages/django/views/__pycache__/debug.cpython-310.pyc
o

�ha�@sjddlZddlZddlZddlZddlZddlZddlmZddlm	Z	ddl
mZmZm
Z
ddlmZmZmZddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
l m!Z!m"Z"edddid�Z#dd�Z$Gdd�de%�Z&Gdd�d�Z'd+dd�Z(ej)dd��Z*dd�Z+dd �Z,d!d"�Z-Gd#d$�d$�Z.Gd%d&�d&�Z/d'd(�Z0d)d*�Z1dS),�N)�Path)�settings)�Http404�HttpResponse�HttpResponseNotFound)�Context�Engine�TemplateDoesNotExist)�pprint)�resolve)�timezone)�MultiValueDict)�	force_str)�
import_string)�_lazy_re_compile)�PY311�get_docs_versionT�i18nzdjango.templatetags.i18n)�debug�	librariescCstt�jd|S)z�
    Return a path to a builtin template.

    Avoid calling this function at the module level or in a class-definition
    because __file__ may not exist, e.g. in frozen environments.
    �	templates)r�__file__�parent)�name�r�H/usr/local/CyberPanel/lib/python3.10/site-packages/django/views/debug.py�builtin_template_pathsrc@seZdZdS)�ExceptionCycleWarningN)�__name__�
__module__�__qualname__rrrrr)src@s eZdZdZdd�Zdd�ZdS)�CallableSettingWrapperz�
    Object to wrap callable appearing in settings.
    * Not to call in the debug page (#21345).
    * Not to break the debug page if the callable forbidding to set attributes
      (#23070).
    cCs
||_dS�N)�_wrapped)�self�callable_settingrrr�__init__5�
zCallableSettingWrapper.__init__cCs
t|j�Sr")�reprr#�r$rrr�__repr__8r'zCallableSettingWrapper.__repr__N)rrr �__doc__r&r*rrrrr!-sr!��cCsFt|�||||�}|�d�r|��}t||d�S|��}t||dd�S)z�
    Create a technical server error response. The last three arguments are
    the values returned from sys.exc_info() and friends.
    z	text/html)�statusztext/plain; charset=utf-8)r-�content_type)�get_exception_reporter_class�accepts�get_traceback_htmlr�get_traceback_text)�request�exc_type�	exc_value�tb�status_code�reporter�html�textrrr�technical_500_response<s
�r;cCsttj��Sr")rr�!DEFAULT_EXCEPTION_REPORTER_FILTERrrrr�%get_default_exception_reporter_filterLsr=cCst�}t|d|�S)N�exception_reporter_filter)r=�getattr)r3�default_filterrrr�get_exception_reporter_filterRsrAcCsttj�}t|d|�S)N�exception_reporter_class)rr�DEFAULT_EXCEPTION_REPORTERr?)r3� default_exception_reporter_classrrrr/Ws��r/cCsB|j}|durzt|j�}Wn	tyYnw|durdS|jS)N�)�resolver_matchr�pathr�
_func_path)r3rFrrr�
get_caller`s�rIc@sjeZdZdZdZedejd�Zdd�Z	dd�Z
d	d
�Zdd�Zd
d�Z
dd�Zdd�Zdd�Zdd�ZdS)�SafeExceptionReporterFilterz�
    Use annotations made by the sensitive_post_parameters and
    sensitive_variables decorators to filter out sensitive information.
    z********************z/API|TOKEN|KEY|SECRET|PASS|SIGNATURE|HTTP_COOKIE)�flagscs�|tjkrd}nz�j�|�}Wntyd}Ynw|r"�j}n3t|t�r3�fdd�|��D�}n"t|t	�rB�fdd�|D�}nt|t
�rSt
�fdd�|D��}n|}t|�r]t|�}|S)z�
        Cleanse an individual setting key/value of sensitive content. If the
        value is a dictionary, recursively cleanse the keys in that dictionary.
        TFc�i|]\}}|��||��qSr��cleanse_setting��.0�k�vr)rr�
<dictcomp>��z?SafeExceptionReporterFilter.cleanse_setting.<locals>.<dictcomp>c�g|]}��d|��qS�rErM�rPrRr)rr�
<listcomp>��z?SafeExceptionReporterFilter.cleanse_setting.<locals>.<listcomp>crUrVrMrWr)rrrX�rY)
r�SESSION_COOKIE_NAME�hidden_settings�search�	TypeError�cleansed_substitute�
isinstance�dict�items�list�tuple�callabler!)r$�key�value�is_sensitive�cleansedrr)rrNus&
�


z+SafeExceptionReporterFilter.cleanse_settingcCs4i}tt�D]}|��r|�|tt|��||<q|S)z�
        Return a dictionary of the settings module with values of sensitive
        settings replaced with stars (*********).
        )�dirr�isupperrNr?)r$�
settings_dictrQrrr�get_safe_settings�s�z-SafeExceptionReporterFilter.get_safe_settingsc�&t|d�siS�fdd�|j��D�S)zU
        Return a dictionary of request.META with sensitive values redacted.
        �METAcrLrrMrOr)rrrS�rTzESafeExceptionReporterFilter.get_safe_request_meta.<locals>.<dictcomp>)�hasattrrnra�r$r3rr)r�get_safe_request_meta��
z1SafeExceptionReporterFilter.get_safe_request_metacrm)zX
        Return a dictionary of request.COOKIES with sensitive values redacted.
        �COOKIEScrLrrMrOr)rrrS�rTz@SafeExceptionReporterFilter.get_safe_cookies.<locals>.<dictcomp>)rorsrarprr)r�get_safe_cookies�rrz,SafeExceptionReporterFilter.get_safe_cookiescCs
tjduS)a
        This filter is to add safety in production environments (i.e. DEBUG
        is False). If DEBUG is True then your site is not safe anyway.
        This hook is provided as a convenience to easily activate or
        deactivate the filter on a per request basis.
        F)r�DEBUGrprrr�	is_active�s
z%SafeExceptionReporterFilter.is_activecCsBt|dg�}|�|�r|r|��}|D]}||vr|j||<q|S)z�
        Replace the keys in a MultiValueDict marked as sensitive with stars.
        This mitigates leaking sensitive POST parameters if something like
        request.POST['nonexistent_key'] throws an exception (#21098).
        �sensitive_post_parameters)r?rv�copyr^)r$r3�multivaluedictrw�paramrrr�get_cleansed_multivaluedict�s
�z7SafeExceptionReporterFilter.get_cleansed_multivaluedictcCsv|duriSt|dg�}|�|�r8|r8|j��}|dkr(|D]}|j||<q|S|D]}||vr5|j||<q*|S|jS)zk
        Replace the values of POST parameters marked as sensitive with
        stars (*********).
        Nrw�__ALL__)r?rv�POSTrxr^)r$r3rwrhrQrzrrr�get_post_parameters�s"�

�z/SafeExceptionReporterFilter.get_post_parametersc
CsTzt|t�}Wnty}zd�||�WYd}~Sd}~ww|r(|�||�}|S)Nz{!r} while evaluating {!r})r_r
�	Exception�formatr{)r$r3rf�is_multivalue_dict�errr�cleanse_special_types�s��z1SafeExceptionReporterFilter.cleanse_special_typesc	Cs|j}d}|dur'|jjdkr d|jvr |jd}t|dd�}n|j}|dus	i}|�|�r]|r]|dkr@|jD]}|j||<q7n/|j��D]\}}||vrQ|j}n|�||�}|||<qEn|j��D]\}}|�||�||<qb|jjdkr�d|jvr�|j|d<|j|d<|��S)ze
        Replace the values of variables marked as sensitive with
        stars (*********).
        N�sensitive_variables_wrapper�sensitive_variablesr|�	func_args�func_kwargs)	�f_back�f_code�co_name�f_localsr?rvr^rar�)	r$r3�tb_frame�
current_framer��wrapperrhrrfrrr�get_traceback_frame_variables�s:

�
�
�	


z9SafeExceptionReporterFilter.get_traceback_frame_variablesN)rrr r+r^r�re�Ir[rNrlrqrtrvr{r~r�r�rrrrrJjs�	rJc@s~eZdZdZedd��Zedd��Zddd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Z	ddd�Z
dd�Zdd�Zdd�ZdS)�ExceptionReporterz0Organize and coordinate reporting on exceptions.cC�td�S)Nztechnical_500.html�rr)rrr�html_template_path'�z$ExceptionReporter.html_template_pathcCr�)Nztechnical_500.txtr�r)rrr�text_template_path+r�z$ExceptionReporter.text_template_pathFcCsJ||_t|j�|_||_||_||_||_t|jdd�|_d|_	d|_
dS)N�template_debugF)r3rA�filterr4r5r6�is_emailr?�
template_info�template_does_not_exist�
postmortem)r$r3r4r5r6r�rrrr&/s
zExceptionReporter.__init__cCs dj|jj|j��|j��d�S)z�
        Return an absolute URI from variables available in this request. Skip
        allowed hosts protection, so may return insecure URI.
        z{scheme}://{host}{path})�scheme�hostrG)r�r3r��
_get_raw_host�
get_full_pathr)rrr�_get_raw_insecure_uri;s
�z'ExceptionReporter._get_raw_insecure_uricCs�|jrt|jt�rd|_|jjp|jg|_|��}t|�D]8\}}d|vrQg}|dD]!\}}t	|�}t
|�dkrEd|dd�t
|�f}|�||f�q+||d<|||<qd}|jr�t|jt�r�t
|jdd�}t
|jd	d�}	|dur�|	dur�|jjd
}
t|
t|dd�t|	dt
|
���dd
d�}ddlm}|jdur�d}nzt|jj�}Wnty�d}Ynwid|j�d|�d|�d|j�d|j�|j��d|j�|j����d|�dt|j�|j�����d|j���dt j!�ddt j"dd��dt#�$��d|��d t j%�d!|j&�d"|j�d#|j�}
|jdu�r7|jj'��|
d$<|jj(��|
d%<|�)�|
d&<t*|j�|
d'<|j�rA|jj+|
d(<|j�r_t|j�|
d)<t
|jd*d�}�r_d+d+�,|�|
d,<|�rh|d-|
d.<|
S)/z5Return a dictionary containing traceback information.T�varsiu%s… <trimmed %d bytes string>rrE�startN�end���ascii�replace)�errors)�get_versionz%[unable to retrieve the current user]r��unicode_hint�framesr3�request_meta�request_COOKIES_items�user_str�filtered_POST_itemsr�sys_executable�sys_version_infoz%d.%d.%d��server_time�django_version_info�sys_pathr�r�r��request_GET_items�request_FILES_items�request_insecure_uri�raising_view_name�exception_type�exception_value�	__notes__�
�exception_notes����	lastframe)-r4�
issubclassr	r�r5�chainr��get_traceback_frames�	enumerater
�len�append�UnicodeErrorr?�argsr�max�min�djangor�r3�str�userrr�r�rqrtrarbr~rl�sys�
executable�version_infor�nowrGr��GET�FILESr�rIr�join)r$r��i�frame�
frame_varsrQrRr�r�r��unicode_strr�r��c�	exc_notesrrr�get_traceback_dataFs�
"�
����������
��
�������z$ExceptionReporter.get_traceback_datacCsV|jjdd��}t�|���}Wd�n1swYt|��dd�}|�|�S)z1Return HTML version of debug 500 HTTP error page.�utf-8��encodingNF)�use_l10n)r��open�DEBUG_ENGINE�from_string�readrr��render�r$�fh�tr�rrrr1�s
�
z$ExceptionReporter.get_traceback_htmlcCsX|jjdd��}t�|���}Wd�n1swYt|��ddd�}|�|�S)z7Return plain text version of debug 500 HTTP error page.r�r�NF)�
autoescaper�)r�r�r�r�r�rr�r�r�rrrr2�s
�
z$ExceptionReporter.get_traceback_textcCs�d}t|d�r z|�|�}Wn	tyYnw|dur |��}|durOz t|d��}|����}Wd�W|S1s=wYW|StyNY|Sw|S)N�
get_source�rb)ror��ImportError�
splitlinesr�r��OSError)r$�filename�loader�module_name�source�fprrr�_get_source�s,
�����zExceptionReporter._get_sourceNcs�|�|||�}|durdgdgfSt|dt�r=d�|dd�D]}t�d|�}|r3|d�d��nq �fdd�|D�}td||�}	||}
z||	|�}||}||d|
�}
WntykdgdgfYSw|	|||
fS)	z�
        Return context_lines before and after lineno from file.
        Return (pre_context_lineno, pre_context, context_line, post_context).
        Nrr��scoding[:=]\s*([-\w.]+)r�csg|]}t|�d��qS)r�)r�)rP�sliner�rrrX�rYz:ExceptionReporter._get_lines_from_file.<locals>.<listcomp>)r�r_�bytesr�r\�decoder��
IndexError)r$r��lineno�
context_linesr�r�r��line�match�lower_bound�upper_bound�pre_context�context_line�post_contextrr�r�_get_lines_from_file�s,��z&ExceptionReporter._get_lines_from_filecCs4t|dd�}t|dd�}t|dd�}|p|rdS|S)N�	__cause__�__suppress_context__�__context__)r?)r$r5�explicit�suppress_context�implicitrrr�_get_explicit_or_implicit_cause�sz1ExceptionReporter._get_explicit_or_implicit_causecCs�g}|j}|r |�|�|�|�}||vrt�d|t�n|sg}|s&|S|��}|s/|jn|j}	|�	|�
||��z|��}Wn
tyLY|Sw|j}q3)NzHCycle in the exception chain detected: exception '%s' encountered again.)r5r�r�warnings�warnr�popr6�
__traceback__�extend�get_exception_traceback_framesr�)r$�
exceptionsr5r�r6rrrr��s:

�����z&ExceptionReporter.get_traceback_framesccs��|�|�}t|dd�}|dur||ddd�V|dur�|jj�d�r'|j}q|jjj}|jjj}|j	d}|jj
�d�}|jj
�d�pEd	}	|�||d
||	�\}
}}}
|
dur_|}
g}d}g}
d	}}tr�t
t�|jj��|jdd��\}}}}|r�|r�d
||}d|tt|d��d}d|�|��}dd|t|�t|���}d|�|��}||||	�d�r�dnd|||d|j�|j|j�t|�|||
|
d||d�V|j}|dusdSdS)NrTr�)�	exc_cause�exc_cause_explicitr6�type�__traceback_hide__r��
__loader__rrE�z<source code not available>r��^� r��zdjango.r�)rrr6rr��functionr�r��idrrr�pre_context_lineno�colno�
tb_area_colno)rr?r�r��get�tb_nextr��co_filenamer��	tb_lineno�	f_globalsrr�next�	itertools�islice�co_positions�tb_lastir�r��lstrip�
startswithr�r�r3r)r$r5r6rrr�rr�r�r�rrrrrr �_�start_column�
end_column�	underline�spaces�tb_area_spacesrrrrs��
�


����������z0ExceptionReporter.get_exception_traceback_frames)F)NN)rrr r+�propertyr�r�r&r�r�r1r2r�rrr�rrrrrr�$s"


P
�$!r�c
Cs�z	|jdd}Wntttfy|jdd�}Ynwz	|jdd}Wntttfy=d}|jr9|jjnd}Yn;wd}|rt|jdkrxt|�dkrxt|d�dkrxt	|ddd	d
�t	|dddd
�krrdkrxt
|�Snt
|�St	|d
tj�}t
|tj�r�|j}td�jdd��}t�|���}Wd�n1s�wYt�}t|tj|||t|�||��t|�d�	�}	t|�|	��S)zBCreate a technical 404 error response. `exception` is the Http404.rrGr�N�triedTF�/�app_namerE�	namespace�admin�urlconfztechnical_404.htmlr�r�)	r9�root_urlconf�request_path�urlpatterns�resolved�reasonr3rr�)r�r�r]�KeyError�	path_inforFr4rGr�r?�default_urlconfr�ROOT_URLCONFr_�types�
ModuleTyperrr�r�r�r�r=rr�rlrIrr�)
r3�	exception�	error_urlr4r=r9r�r��reporter_filterr�rrr�technical_404_responseNsX��
������
rHcCsZtd�jdd��}t�|���}Wd�n1swYtdt�i�}t|�|��S)z+Create an empty URLconf 404 error response.zdefault_urlconf.htmlr�r�N�version)	rr�r�r�r�rrrr�)r3r�r�r�rrrrA}s���rA)r,)2�	functoolsr'r�r�rCr�pathlibr�django.confr�django.httprrr�django.templaterrr	�django.template.defaultfiltersr
�django.urlsr�django.utilsr�django.utils.datastructuresr
�django.utils.encodingr�django.utils.module_loadingr�django.utils.regex_helperr�django.utils.versionrrr�r�UserWarningrr!r;�	lru_cacher=rAr/rIrJr�rHrArrrr�<module>sL�


	
;,/