Ë
    Q^(h¡:  ã                   óp  — U d Z ddlZddlZddlZddlmZ ddlmZ ddlm	Z	 ddl
mZ ddlmZ ddlmZ dd	lmZ d
dlmZ d
dlmZ d
dlmZ d
dlmZ  ej0                  dej2                  dej4                  f   ¬«      ZdZ e«       Zej>                  e    e!d<    e«       Z"ej>                  e    e!d<   ddhZ#ddhZ$ddhZ%ejL                   e'g d¢«      fejP                   e'g d¢«      fejR                   e'g d¢«      fe	 e'g d¢«      ffZ*ejV                  ejV                  ejX                  ej4                     ejZ                  e    f   df   e!d<   d e.d!e/fd"„Z0d#ed!efd$„Z1d%ej4                  d&e d!e2fd'„Z3d%ej4                  d&e d!e2fd(„Z4 G d)„ d*e«      Z5 G d+„ d,e5«      Z6 G d-„ d.e«      Z7 G d/„ d0e7e«      Z8y)1z„A sandbox layer that ensures unsafe operations cannot be performed.
Useful when the template itself comes from an untrusted source.
é    N)Úformatter_field_name_split)Úabc)Údeque)Úupdate_wrapper)Ú	Formatter)ÚEscapeFormatter)ÚMarkupé   )ÚEnvironment)ÚSecurityError)ÚContext)Ú	UndefinedÚF.)Úboundi † ÚUNSAFE_FUNCTION_ATTRIBUTESÚUNSAFE_METHOD_ATTRIBUTESÚgi_frameÚgi_codeÚcr_frameÚcr_codeÚag_codeÚag_frame)ÚaddÚclearÚdifference_updateÚdiscardÚpopÚremoveÚsymmetric_difference_updateÚupdate)r   r   ÚpopitemÚ
setdefaultr    )Úappendr   r   ÚreverseÚinsertÚsortÚextendr   )	r#   Ú
appendleftr   r'   Ú
extendleftr   Úpopleftr   ÚrotateÚ_mutable_specÚargsÚreturnc                  ó`   — t        | Ž }t        |«      t        kD  rt        dt        › d�«      ‚|S )zWA range that can't generate ranges with a length of more than
    MAX_RANGE items.
    z@Range too big. The sandbox blocks ranges larger than MAX_RANGE (z).)ÚrangeÚlenÚ	MAX_RANGEÚOverflowError)r-   Úrngs     úL/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/jinja2/sandbox.pyÚ
safe_ranger6   W   s>   € ô �ˆ,€Cä
ˆ3ƒx”)ÒÜðÜ$˜+ Rð)ó
ð 	
ð
 €Jó    Úfc                 ó   — d| _         | S )z�Marks a function or method as unsafe.

    .. code-block: python

        @unsafe
        def delete(self):
            pass
    T)Úunsafe_callable)r8   s    r5   Úunsafer;   f   s   € ð €AÔØ€Hr7   ÚobjÚattrc                 ót  — t        | t        j                  «      r
|t        v �ryt        | t        j                  «      r|t        v s|t
        v rÚyt        | t        «      r|dk(  rÄyt        | t        j                  t        j                  t        j                  f«      ryt        | t        j                  «      r	|t        v rgyt        t        d«      r#t        | t        j                  «      r	|t        v r4yt        t        d«      r#t        | t        j                  «      r	|t         v ry|j#                  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ÚFunctionTyper   Ú
MethodTyper   ÚtypeÚCodeTypeÚTracebackTypeÚ	FrameTypeÚGeneratorTypeÚUNSAFE_GENERATOR_ATTRIBUTESÚhasattrr@   ÚUNSAFE_COROUTINE_ATTRIBUTESrA   Ú!UNSAFE_ASYNC_GENERATOR_ATTRIBUTESÚ
startswith)r<   r=   s     r5   Úis_internal_attributerQ   s   sõ   € ô �#”u×)Ñ)Ô*ØÔ-Ò-ØÜ	�Cœ×)Ñ)Ô	*ØÔ-Ñ-°Ô9QÑ1QØÜ	�CœÔ	Ø�5Š=ØÜ	�Cœ%Ÿ.™.¬%×*=Ñ*=¼u¿¹ÐOÔ	PØÜ	�Cœ×,Ñ,Ô	-ØÔ.Ñ.ØÜ	”˜Ô	(¬Z¸¼U×=PÑ=PÔ-QØÔ.Ñ.ØÜ	”Ð,Ô	-´*ØŒU×%Ñ%ô3ð Ô4Ñ4ØØ�?‰?˜4Ó Ð r7   c                 óD   — t         D ]  \  }}t        | |«      sŒ||v c S  y)að  This function checks if an attribute on a builtin mutable object
    (list, dict, set or deque) or the corresponding ABCs would modify it
    if called.

    >>> 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, ``False`` is returned.

    >>> modifies_known_mutable("foo", "upper")
    False
    F)r,   rC   )r<   r=   Útypespecr;   s       r5   Úmodifies_known_mutablerT   ˜   s1   € ô& *ò "Ñˆ�&Ü�c˜8Õ$Ø˜6�>Ò!ð"ð r7   c            
       ó\  ‡ — e Zd ZU dZdZej                  ej                  ej                  ej                  ej                  ej                  ej                  dœZej                  eej"                  ej$                  ej$                  gej$                  f   f   ed<   ej(                  ej*                  dœZej                  eej"                  ej$                  gej$                  f   f   ed<    e«       Zej2                  e   ed<    e«       Zej2                  e   ed<   d	ej$                  d
ej$                  ddfˆ fd„Zdej$                  dedej$                  defd„Zdej$                  defd„Zdededej$                  dej$                  dej$                  f
d„Z dededej$                  dej$                  fd„Z!dej$                  dejD                  eej$                  f   dejD                  ej$                  e#f   fd„Z$dej$                  dedejD                  ej$                  e#f   fd„Z%dej$                  dede#fd„Z&dej$                  dejN                  ej"                  def      fd „Z(d!ed"ej$                  d	ej$                  d
ej$                  dej$                  f
d#„Z)ˆ xZ*S )$ÚSandboxedEnvironmentaé  The sandboxed environment.  It works like the regular environment but
    tells the compiler to generate sandboxed code.  Additionally subclasses of
    this environment may override the methods that tell the runtime what
    attributes or functions are safe to access.

    If the template tries to access insecure code a :exc:`SecurityError` is
    raised.  However also other exceptions may occur during the rendering so
    the caller has to ensure that all exceptions are caught.
    T)ú+ú-Ú*ú/z//z**ú%Údefault_binop_table)rW   rX   Údefault_unop_tableÚintercepted_binopsÚintercepted_unopsr-   Úkwargsr.   Nc                 óÆ   •— t        ‰| �  |i |¤Ž t        | j                  d<   | j                  j                  «       | _        | j                  j                  «       | _        y )Nr0   )	ÚsuperÚ__init__r6   Úglobalsr\   ÚcopyÚbinop_tabler]   Ú
unop_table)Úselfr-   r`   Ú	__class__s      €r5   rc   zSandboxedEnvironment.__init__ò   sP   ø€ Ü‰Ñ˜$Ð) &Ò)Ü *ˆ�‰�WÑØ×3Ñ3×8Ñ8Ó:ˆÔØ×1Ñ1×6Ñ6Ó8ˆ�r7   r<   r=   Úvaluec                 óB   — |j                  d«      xs t        ||«       S )aY  The sandboxed environment will call this method to check if the
        attribute of an object is safe to access.  Per default all attributes
        starting with an underscore are considered private as well as the
        special attributes of internal python objects as returned by the
        :func:`is_internal_attribute` function.
        Ú_)rP   rQ   )rh   r<   r=   rj   s       r5   Úis_safe_attributez&SandboxedEnvironment.is_safe_attributeø   s#   € ð —O‘O CÓ(ÒLÔ,AÀ#ÀtÓ,LÐMÐMr7   c                 ó<   — t        |dd«      xs t        |dd«       S )zêCheck if an object is safely callable. By default callables
        are considered safe unless decorated with :func:`unsafe`.

        This also recognizes the Django convention of setting
        ``func.alters_data = True``.
        r:   FÚalters_data)Úgetattr)rh   r<   s     r5   Úis_safe_callablez%SandboxedEnvironment.is_safe_callable  s*   € ô �CÐ*¨EÓ2ÒX´g¸cÀ=ÐRWÓ6Xð
ð 	
r7   ÚcontextÚoperatorÚleftÚrightc                 ó.   —  | j                   |   ||«      S )z÷For intercepted binary operator calls (:meth:`intercepted_binops`)
        this function is executed instead of the builtin operator.  This can
        be used to fine tune the behavior of certain operators.

        .. versionadded:: 2.6
        )rf   )rh   rr   rs   rt   ru   s        r5   Ú
call_binopzSandboxedEnvironment.call_binop  s   € ð *ˆt×Ñ Ñ)¨$°Ó6Ð6r7   Úargc                 ó,   —  | j                   |   |«      S )zõFor intercepted unary operator calls (:meth:`intercepted_unops`)
        this function is executed instead of the builtin operator.  This can
        be used to fine tune the behavior of certain operators.

        .. versionadded:: 2.6
        )rg   )rh   rr   rs   rx   s       r5   Ú	call_unopzSandboxedEnvironment.call_unop  s   € ð )ˆt�‰˜xÑ(¨Ó-Ð-r7   Úargumentc                 óp  — 	 ||   S # t         t        f$ rŒ t        |t        «      ry	 t        |«      }	 t	        ||«      }| j                  |«      }|�|cY S | j                  |||«      r|cY S | j                  ||«      cY S # t        $ r Y nw xY w# t        $ r Y nw xY wY nw xY w| j                  ||¬«      S )z(Subscribe an object from sandboxed code.©r<   Úname)Ú	TypeErrorÚLookupErrorrC   Ústrrp   Úwrap_str_formatrm   Úunsafe_undefinedÚAttributeErrorÚ	ExceptionÚ	undefined)rh   r<   r{   r=   rj   Úfmts         r5   ÚgetitemzSandboxedEnvironment.getitem   sÕ   € ð	DØ�x‘=Ð øÜœ;Ð'ò 	DÜ˜(¤CÔ(ðDÜ˜x›=�Dð
DÜ '¨¨TÓ 2˜ð #×2Ñ2°5Ó9˜Ø˜?Ø#&šJØ×1Ñ1°#°xÀÔGØ#(šLØ#×4Ñ4°S¸(ÓCÒCøô *ò Ùðûô !ò Ùðüð		Dúð$ �~‰~ #¨Hˆ~Ó5Ð5sZ   ‚ ‡B"§B³B¿B"ÁB"Á-B"Â	BÂ
B"ÂBÂB"Â	BÂB"ÂBÂB"Â!B"Ú	attributec                 ó  — 	 t        ||«      }| j                  |«      }|�|S | j                  |||«      r|S | j                  ||«      S # t        $ r  	 ||   cY S # t
        t        f$ r Y nw xY wY nw xY w| j                  ||¬«      S )z€Subscribe an object from sandboxed code and prefer the
        attribute.  The attribute passed *must* be a bytestring.
        r}   )rp   r‚   rm   rƒ   r„   r   r€   r†   )rh   r<   r‰   rj   r‡   s        r5   rp   zSandboxedEnvironment.getattr:  s¨   € ð	9Ü˜C Ó+ˆEð ×&Ñ& uÓ-ˆCØˆØ�
Ø×%Ñ% c¨9°eÔ<Ø�Ø×(Ñ(¨¨iÓ8Ð8øô ò 	ðØ˜9‘~Ò%øÜœ{Ð+ò ÙðúÙð		úð �~‰~ #¨Iˆ~Ó6Ð6s5   ‚A
 Á
	A3ÁAÁA3ÁA-Á*A3Á,A-Á-A3Á2A3c                 óh   — | j                  d|›dt        |«      j                  ›d�||t        ¬«      S )z1Return an undefined object for unsafe attributes.zaccess to attribute z of z object is unsafe.)r~   r<   Úexc)r†   rG   Ú__name__r   )rh   r<   r‰   s      r5   rƒ   z%SandboxedEnvironment.unsafe_undefinedN  sE   € à�~‰~Ø" 9 -ð 0Ü�S“	×"Ñ"Ð%Ð%7ð9àØÜð ó 
ð 	
r7   .c                 óÞ  ‡‡‡‡— t        |t        j                  t        j                  f«      r|j                  dvry|j
                  Št        ‰t        «      syt        ‰«      Š|j                  dk(  Št        ‰t        «      rt        | ‰j                  ¬«      }nt        | «      }|j                  Šdt        j                  dt        j                  dt        fˆˆˆˆfd„}t        ||«      S )	a   If the given value is a ``str.format`` or ``str.format_map`` method,
        return a new function than handles sandboxing. This is done at access
        rather than in :meth:`call`, so that calls made without ``call`` are
        also sandboxed.
        )ÚformatÚ
format_mapNr�   )Úescaper-   r`   r.   c                  óœ   •— ‰r:|rt        d«      ‚t        | «      dk7  rt        dt        | «      › d�«      ‚| d   }d}  ‰ ‰‰| |«      «      S )Nz'format_map() takes no keyword argumentsr
   z)format_map() takes exactly one argument (z given)r   © )r   r1   )r-   r`   Úf_selfÚis_format_mapÚstr_typeÚvformats     €€€€r5   Úwrapperz5SandboxedEnvironment.wrap_str_format.<locals>.wrappers  sa   ø€ ÙÙÜ#Ð$MÓNÐNä�t“9 ’>Ü#ØCÄCÈÃIÀ;ÈgÐVóð ð ˜a™�Ø�á™G F¨D°&Ó9Ó:Ð:r7   )rC   rD   rF   ÚBuiltinMethodTyper�   Ú__self__r�   rG   r	   ÚSandboxedEscapeFormatterr‘   ÚSandboxedFormatterr—   ÚtÚAnyr   )rh   rj   Ú	formatterr˜   r”   r•   r–   r—   s       @@@@r5   r‚   z$SandboxedEnvironment.wrap_str_formatX  sÇ   û€ ô Ø”E×$Ñ$¤e×&=Ñ&=Ð>ô
à�^‰^Ð#;Ñ;ØàŸ™ˆä˜&¤#Ô&Øä $ V£ˆØŸ™¨,Ñ6ˆô �fœfÔ%Ü0°¸f¿m¹mÔL‰Iä*¨4Ó0ˆIà×#Ñ#ˆð	;œ1Ÿ5™5ð 	;¬A¯E©Eð 	;´c÷ 	;ð 	;ô ˜g uÓ-Ð-r7   Ú_SandboxedEnvironment__contextÚ_SandboxedEnvironment__objc                 ól   — | j                  |«      st        |›d�«      ‚ |j                  |g|¢­i |¤ŽS )z#Call an object from sandboxed code.z is not safely callable)rq   r   Úcall)Ú_SandboxedEnvironment__selfr    r¡   r-   r`   s        r5   r£   zSandboxedEnvironment.call„  s@   € ð ×&Ñ& uÔ-Ü 5 )Ð+BÐ CÓDÐDØˆy�~‰~˜eÐ5 dÒ5¨fÑ5Ð5r7   )+r�   Ú
__module__Ú__qualname__Ú__doc__Ú	sandboxedrs   r   ÚsubÚmulÚtruedivÚfloordivÚpowÚmodr\   r�   ÚDictr�   ÚCallablerž   Ú__annotations__ÚposÚnegr]   Ú	frozensetr^   Ú	FrozenSetr_   rc   Úboolrm   rq   r   rw   rz   ÚUnionr   rˆ   rp   rƒ   ÚOptionalr‚   r£   Ú__classcell__©ri   s   @r5   rV   rV   ±   sÅ  ø… ñð €Ið �\‰\Ø�\‰\Ø�\‰\Ø×ÑØ×ÑØ�l‰lØ�\‰\ñKÐ˜Ÿ™  Q§Z¡Z°·±¸¿¹°ÀÇÁÐ0EÑ%FÐ FÑGó ð �\‰\Ø�\‰\ñCÐ˜Ÿ™˜s A§J¡J°·±¨w¸¿¹¨~Ñ$>Ð>Ñ?ó ñ& ,5«;Ð˜Ÿ™ CÑ(Ó6ñ +4«+Ð�q—{‘{ 3Ñ'Ó5ð9˜aŸe™eð 9¨q¯u©uð 9¸õ 9ðN Q§U¡Uð N°#ð N¸a¿e¹eð NÈó Nð	
 A§E¡Eð 	
¨dó 	
ð	7Øð	7Ø*-ð	7Ø56·U±Uð	7ØCDÇ5Á5ð	7à	
�‰ó	7ð. ð .°Cð .¸a¿e¹eð .ÈÏÉó .ð6Ø—5‘5ð6Ø$%§G¡G¨C°·±¨JÑ$7ð6à	
�‰�—‘˜	Ð!Ñ	"ó6ð47˜1Ÿ5™5ð 7¨Sð 7°Q·W±W¸Q¿U¹UÀIÐ=MÑ5Nó 7ð(
 A§E¡Eð 
°cð 
¸ió 
ð*. Q§U¡Uð *.¨q¯z©z¸!¿*¹*ÀSÈ#ÀXÑ:NÑ/Oó *.ðX6àð6ð �u‰uð6ð �u‰uð	6ð
 —%‘%ð6ð 
�‰÷6r7   rV   c                   ó\   ‡ — e Zd ZdZdej
                  dedej
                  defˆ fd„Zˆ xZ	S )ÚImmutableSandboxedEnvironmentzÓWorks exactly like the regular `SandboxedEnvironment` but does not
    permit modifications on the builtin mutable objects `list`, `set`, and
    `dict` by using the :func:`modifies_known_mutable` function.
    r<   r=   rj   r.   c                 óB   •— t         ‰| �  |||«      syt        ||«       S )NF)rb   rm   rT   )rh   r<   r=   rj   ri   s       €r5   rm   z/ImmutableSandboxedEnvironment.is_safe_attributeš  s'   ø€ Ü‰wÑ(¨¨d°EÔ:Øä)¨#¨tÓ4Ð4Ð4r7   )
r�   r¥   r¦   r§   r�   rž   r�   r¶   rm   r¹   rº   s   @r5   r¼   r¼   ”  s6   ø„ ñð
5 Q§U¡Uð 5°#ð 5¸a¿e¹eð 5È÷ 5ñ 5r7   r¼   c            
       óê   ‡ — e Zd Zdedej
                  ddfˆ fd„Zdedej                  ej
                     dej                  eej
                  f   dej                  ej
                  ef   fd„Zˆ xZS )	rœ   Úenvr`   r.   Nc                 ó2   •— || _         t        ‰| �  di |¤Ž y )Nr“   )Ú_envrb   rc   )rh   r¿   r`   ri   s      €r5   rc   zSandboxedFormatter.__init__¢  s   ø€ ØˆŒ	Ü‰ÑÑ"˜6Ó"r7   Ú
field_namer-   c                 óÖ   — t        |«      \  }}| j                  |||«      }|D ]@  \  }}|r| j                  j                  ||«      }Œ%| j                  j	                  ||«      }ŒB ||fS )N)r   Ú	get_valuerÁ   rp   rˆ   )	rh   rÂ   r-   r`   ÚfirstÚrestr<   Úis_attrÚis	            r5   Ú	get_fieldzSandboxedFormatter.get_field¦  sr   € ô 1°Ó<‰ˆˆtØ�n‰n˜U D¨&Ó1ˆØò 	0‰JˆG�QÙØ—i‘i×'Ñ'¨¨QÓ/‘à—i‘i×'Ñ'¨¨QÓ/‘ð		0ð
 �EˆzÐr7   )r�   r¥   r¦   r   r�   rž   rc   r�   ÚSequenceÚMappingÚTuplerÉ   r¹   rº   s   @r5   rœ   rœ   ¡  su   ø„ ð#˜Kð #°1·5±5ð #¸Tõ #ð
Øð
Ø%&§Z¡Z°·±Ñ%6ð
Ø@AÇ	Á	È#ÈqÏuÉuÈ*Ñ@Uð
à	
�‰�—‘˜�Ñ	÷
r7   rœ   c                   ó   — e Zd Zy)r›   N)r�   r¥   r¦   r“   r7   r5   r›   r›   ³  s   „ Ør7   r›   )9r§   rs   rD   Útypingr�   Ú_stringr   Úcollectionsr   r   Ú	functoolsr   Ústringr   Ú
markupsafer   r	   Úenvironmentr   Ú
exceptionsr   Úruntimer   r   ÚTypeVarr°   rž   r   r2   Úsetr   ÚSetr�   r±   r   rL   rN   rO   Ú
MutableSetr´   ÚMutableMappingÚMutableSequencer,   rÌ   ÚTyperµ   Úintr0   r6   r;   r¶   rQ   rT   rV   r¼   rœ   r›   r“   r7   r5   ú<module>rß      sö  ðòó Û Û Ý .Ý Ý Ý $Ý å &Ý å $Ý %Ý Ý à€A‡I�Iˆc˜Ÿ™ C¨¯© JÑ/Ô0€ð €	ñ *-«Ð ˜AŸE™E #™JÓ .ñ (+£uÐ ˜!Ÿ%™% ™*Ó ,ð  *¨9Ð5Ð ð  *¨9Ð5Ð ð &/°
Ð$;Ð !ð 	�‰Ùò	ó	
ðð  	×ÑÙÒEÓFðð
 	×ÑÙÚWó	
ðð 	Ùò
ó	
ðð5*I€ˆq�w‰w�q—w‘w˜qŸv™v a§e¡e™}¨a¯k©k¸#Ñ.>Ð>Ñ?ÀÐDÑEó *ðZ�cð ˜eó ð
ˆað 
�Aó 
ð"!˜qŸu™uð "!¨Cð "!°Dó "!ðJ §¡ð ¨Sð °Tó ô2`6˜;ô `6ôF
5Ð$8ô 
5ô˜ô ô$	Ð1°?õ 	r7   