Dashboard
PHP:
8.1.34
OS:
Linux
User:
uid288609
/
/
usr
/
lib
/
python3
/
dist-packages
/
jinja2
/
__pycache__
📤 Upload
📝 New File
📁 New Folder
Close
Editing: sandbox.cpython-39.pyc
a ��h�A � @ s� d Z ddlZddlZddlZddlmZ ddlmZ zddlm Z W n e yb ddlm Z Y n0 ddlm Z ddlmZ dd lmZ dd lmZ ddlmZ ddlmZ dd lmZ ddlmZ dZer�h d�Zne� Zh d�ZddhZddhZddhZejdde e!d� efZ"e#fZ$e%fZ&z6ddl'm'Z'm(Z( ddl)m)Z) e$e'e(f7 Z$e"e)f7 Z"W n e �yj Y n0 zddl*m+Z+ e"e+f7 Z"W n e �y� Y n0 e"ej,f7 Z"e$ej-f7 Z$e&ej.f7 Z&e"e/g d��fe$e/g d��fe&e/g d ��fe e/g d!��ffZ0d"d#� Z1d$d%� Z2d&d'� Z3d(d)� Z4G d*d+� d+e�Z5G d,d-� d-e5�Z6zdd.l7m8Z8 W n e �yh d/d0� Z8Y n0 G d1d2� d2e9�Z:G d3d4� d4e:e�Z;G d5d6� d6e:e �Z<dS )7z�A sandbox layer that ensures unsafe operations cannot be performed. Useful when the template itself comes from an untrusted source. � N)�update_wrapper)� Formatter)�deque)�EscapeFormatter)�Markup� )�abc)�PY2)� range_type)�string_types)�Environment)� SecurityErrori�� > Z func_codeZ func_defaultsZ func_dictZfunc_closureZfunc_globals> Zim_funcZim_classZim_self�gi_frame�gi_code�cr_frame�cr_code�ag_code�ag_frame�ignorezthe sets module)�module)�UserDict� DictMixin)�UserList)�Set)�add�clear�difference_update�discard�pop�remove�symmetric_difference_update�update)r r �popitem� setdefaultr! )�append�reverse�insert�sort�extendr ) r$ � appendleftr r( � extendleftr �popleftr �rotatec G s$ t | � }t|�tkr tdt ��|S )zWA range that can't generate ranges with a length of more than MAX_RANGE items. zDRange too big. The sandbox blocks ranges larger than MAX_RANGE (%d).)r �len� MAX_RANGE� OverflowError)�args�rng� r2 �0/usr/lib/python3/dist-packages/jinja2/sandbox.py� safe_range� s ��r4 c C s d| _ | S )znMarks a function or method as unsafe. :: @unsafe def delete(self): pass T)�unsafe_callable)�fr2 r2 r3 �unsafe� s r7 c C s� t | tj�r|tv r�dS n�t | tj�r<|tv s6|tv r�dS n�t | t�rT|dkr�dS nzt | tjtjtj f�rndS t | tj �r�|tv r�dS nFttd�r�t | tj �r�|tv r�dS n"ttd�r�t | tj�r�|tv r�dS |�d�S )a� Test if the attribute given is an internal python attribute. For example this function returns `True` for the `func_code` attribute of python objects. This is useful if the environment method :meth:`~SandboxedEnvironment.is_safe_attribute` is overridden. >>> from jinja2.sandbox import is_internal_attribute >>> is_internal_attribute(str, "mro") True >>> is_internal_attribute(str, "upper") False T�mro� CoroutineType�AsyncGeneratorType�__)� isinstance�types�FunctionType�UNSAFE_FUNCTION_ATTRIBUTES� MethodType�UNSAFE_METHOD_ATTRIBUTES�type�CodeType� TracebackType� FrameType� GeneratorType�UNSAFE_GENERATOR_ATTRIBUTES�hasattrr9 �UNSAFE_COROUTINE_ATTRIBUTESr: �!UNSAFE_ASYNC_GENERATOR_ATTRIBUTES� startswith)�obj�attrr2 r2 r3 �is_internal_attribute� s. �rN c C s( t D ]\}}t| |�r||v S qdS )a� This function checks if an attribute on a builtin mutable object (list, dict, set or deque) would modify it if called. It also supports the "user"-versions of the objects (`sets.Set`, `UserDict.*` etc.) and with Python 2.6 onwards the abstract base classes `MutableSet`, `MutableMapping`, and `MutableSequence`. >>> modifies_known_mutable({}, "clear") True >>> modifies_known_mutable({}, "keys") False >>> modifies_known_mutable([], "append") True >>> modifies_known_mutable([], "index") False If called with an unsupported object (such as unicode) `False` is returned. >>> modifies_known_mutable("foo", "upper") False F)� _mutable_specr<