ÿØÿàJFIFÿþ ÿÛC       ÿÛC ÿÀÿÄÿÄ"#QrÿÄÿÄ&1!A"2qQaáÿÚ ?Øy,æ/3JæÝ¹È߲؋5êXw²±ÉyˆR”¾I0ó2—PI¾IÌÚiMö¯–þrìN&"KgX:Šíµ•nTJnLK„…@!‰-ý ùúmë;ºgµŒ&ó±hw’¯Õ@”Ü— 9ñ-ë.²1<yà‚¹ïQÐU„ہ?.’¦èûbß±©Ö«Âw*VŒ) `$‰bØÔŸ’ëXÖ-ËTÜíGÚ3ð«g Ÿ§¯—Jx„–’U/ÂÅv_s(Hÿ@TñJÑãõçn­‚!ÈgfbÓc­:él[ðQe 9ÀPLbÃãCµm[5¿ç'ªjglå‡Ûí_§Úõl-;"PkÞÞÁQâ¼_Ñ^¢SŸx?"¸¦ùY騐ÒOÈ q’`~~ÚtËU¹CڒêV  I1Áß_ÿÙ DaYc@sdZddlZddlZddlmZddlmZddlmZddl m Z m Z ddl m Z ddlmZdd lmZd Ze red d d ddgZn eZedddgZeddgZeddgZeddgZddlZejddeddddlmZefZefZe fZ!yGddl"m"Z"m#Z#ddl$m$Z$ee"e#f7Zee$f7ZWne%k rnXy!dd l&m'Z'ee'f7ZWne%k rnXdd!lm(Z(m)Z)m*Z*ee(f7Zee)f7Ze!e*f7Z!ee+d"d#d$d%d&d'd(d)gfee+d#d&d*d+d)gfe!e+d,d-d.d/d0d'gfee+d,d1d#d0d2d&d3d'd4g ffZ,d5efd6YZ-d7Z.d8Z/d9Z0d:Z1d;Z2d<efd=YZ3d>e3fd?YZ4ydd@l5m6Z6Wne%k rjdAZ6nXdBe7fdCYZ8dDe8efdEYZ9dFe8efdGYZ:dS(Hsj jinja2.sandbox ~~~~~~~~~~~~~~ Adds a sandbox layer to Jinja as it was the default behavior in the old Jinja 1 releases. This sandbox is slightly different from Jinja 1 as the default behavior is easier to use. The behavior can be changed by subclassing the environment. :copyright: (c) 2017 by the Jinja Team. :license: BSD. iN(tMapping(t Environment(t SecurityError(t string_typestPY2(tMarkup(tEscapeFormatter(t Formatterit func_closuret func_codet func_dictt func_defaultst func_globalstim_classtim_functim_selftgi_frametgi_codetcr_frametcr_codetag_codetag_frametignoresthe sets moduletmodulesjinja2.sandbox(tdeque(tUserDictt DictMixin(tUserList(tSet(t MutableSettMutableMappingtMutableSequencetaddtcleartdifference_updatetdiscardtpoptremovetsymmetric_difference_updatetupdatetpopitemt setdefaulttappendtreversetinserttsorttextendt appendleftt extendlefttpoplefttrotatet_MagicFormatMappingcBs2eZdZdZdZdZdZRS(sThis class implements a dummy wrapper to fix a bug in the Python standard library for string formatting. See https://bugs.python.org/issue13598 for information about why this is necessary. cCs||_||_d|_dS(Ni(t_argst_kwargst _last_index(tselftargstkwargs((s2/usr/lib/python2.7/site-packages/jinja2/sandbox.pyt__init__rs  cCsa|dkrV|j}|jd7_y|j|SWntk rFnXt|}n|j|S(Nti(R6R4t LookupErrortstrR5(R7tkeytidx((s2/usr/lib/python2.7/site-packages/jinja2/sandbox.pyt __getitem__ws   cCs t|jS(N(titerR5(R7((s2/usr/lib/python2.7/site-packages/jinja2/sandbox.pyt__iter__scCs t|jS(N(tlenR5(R7((s2/usr/lib/python2.7/site-packages/jinja2/sandbox.pyt__len__s(t__name__t __module__t__doc__R:R@RBRD(((s2/usr/lib/python2.7/site-packages/jinja2/sandbox.pyR3js   cCsOt|tjtjf s+|jdkr/dS|j}t|trK|SdS(Ntformat(t isinstancettypest MethodTypetBuiltinMethodTypeREtNonet__self__R(tcallabletobj((s2/usr/lib/python2.7/site-packages/jinja2/sandbox.pytinspect_format_methods  cGs5t|}t|tkr1tdtn|S(sWA range that can't generate ranges with a length of more than MAX_RANGE items. s+range too big, maximum size for range is %d(trangeRCt MAX_RANGEt OverflowError(R8trng((s2/usr/lib/python2.7/site-packages/jinja2/sandbox.pyt safe_ranges   cCs t|_|S(snMarks a function or method as unsafe. :: @unsafe def delete(self): pass (tTruetunsafe_callable(tf((s2/usr/lib/python2.7/site-packages/jinja2/sandbox.pytunsafes cCs7t|tjr%|tkr*tSnt|tjrV|tksO|tkr*tSnt|trx|dkr*tSnt|tjtj tj frtSt|tj r|t kr*tSnht tdrt|tjr|tkr*tSn4t tdr*t|tjr*|tkr*tSn|jdS(sTest 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 tmrot CoroutineTypetAsyncGeneratorTypet__(RIRJt FunctionTypetUNSAFE_FUNCTION_ATTRIBUTESRWRKtUNSAFE_METHOD_ATTRIBUTESttypetCodeTypet TracebackTypet FrameTypet GeneratorTypetUNSAFE_GENERATOR_ATTRIBUTESthasattrR\tUNSAFE_COROUTINE_ATTRIBUTESR]t!UNSAFE_ASYNC_GENERATOR_ATTRIBUTESt startswith(RPtattr((s2/usr/lib/python2.7/site-packages/jinja2/sandbox.pytis_internal_attributes,     ! ! ! cCs4x-tD]%\}}t||r||kSqWtS(sThis 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 (t _mutable_specRItFalse(RPRlttypespecRZ((s2/usr/lib/python2.7/site-packages/jinja2/sandbox.pytmodifies_known_mutablestSandboxedEnvironmentcBseZdZeZiejd6ejd6ejd6ej d6ej d6ej d6ej d6Z iejd6ejd6ZeZeZdZd Zd Zd Zd Zd ZdZdZdZdZdZRS(sThe 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+t-t*t/s//s**t%cCstS(sCalled during template compilation with the name of a unary operator to check if it should be intercepted at runtime. If this method returns `True`, :meth:`call_unop` is excuted for this unary operator. The default implementation of :meth:`call_unop` will use the :attr:`unop_table` dictionary to perform the operator with the same logic as the builtin one. The following unary operators are interceptable: ``+`` and ``-`` Intercepted calls are always slower than the native operator call, so make sure only to intercept the ones you are interested in. .. versionadded:: 2.6 (Ro(R7toperator((s2/usr/lib/python2.7/site-packages/jinja2/sandbox.pytintercept_unop+scOsHtj|||t|jd<|jj|_|jj|_dS(NRR( RR:RVtglobalstdefault_binop_tabletcopyt binop_tabletdefault_unop_tablet unop_table(R7R8R9((s2/usr/lib/python2.7/site-packages/jinja2/sandbox.pyR:=s cCs|jdpt|| S(sYThe 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. t_(RkRm(R7RPRltvalue((s2/usr/lib/python2.7/site-packages/jinja2/sandbox.pytis_safe_attributeCscCs#t|dtp!t|dt S(sCheck if an object is safely callable. Per default a function is considered safe unless the `unsafe_callable` attribute exists and is True. Override this method to alter the behavior, but this won't affect the `unsafe` decorator from this module. RXt alters_data(tgetattrRo(R7RP((s2/usr/lib/python2.7/site-packages/jinja2/sandbox.pytis_safe_callableLscCs|j|||S(sFor 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 (R}(R7tcontextRxtlefttright((s2/usr/lib/python2.7/site-packages/jinja2/sandbox.pyt call_binopUscCs|j||S(sFor 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 (R(R7RRxtarg((s2/usr/lib/python2.7/site-packages/jinja2/sandbox.pyt call_unop^scCsy ||SWnttfk rt|tryt|}Wntk rTqXyt||}Wntk r{qX|j|||r|S|j ||SqnX|j d|d|S(s(Subscribe an object from sandboxed code.RPtname( t TypeErrorR<RIRR=t ExceptionRtAttributeErrorRtunsafe_undefinedt undefined(R7RPtargumentRlR((s2/usr/lib/python2.7/site-packages/jinja2/sandbox.pytgetitemgs    cCsyt||}Wn7tk rLy ||SWqvttfk rHqvXn*X|j|||rf|S|j||S|jd|d|S(sSubscribe an object from sandboxed code and prefer the attribute. The attribute passed *must* be a bytestring. RPR(RRRR<RRR(R7RPt attributeR((s2/usr/lib/python2.7/site-packages/jinja2/sandbox.pyR|s  cCs/|jd||jjfd|d|dtS(s1Return an undefined object for unsafe attributes.s.access to attribute %r of %r object is unsafe.RRPtexc(Rt __class__RER(R7RPR((s2/usr/lib/python2.7/site-packages/jinja2/sandbox.pyRs cCsdt|tr$t||j}n t|}t||}|j|||}t||S(sIf a format call is detected, then this is routed through this method so that our safety sandbox can be used for it. (RIRtSandboxedEscapeFormattertescapetSandboxedFormatterR3tvformatRb(R7tsR8R9t formattertrv((s2/usr/lib/python2.7/site-packages/jinja2/sandbox.pyt format_strings  cOsct|}|dk r+|j|||S|j|sPtd|fn|j|||S(s#Call an object from sandboxed code.s%r is not safely callableN(RQRMRRRtcall(t_SandboxedEnvironment__selft_SandboxedEnvironment__contextt_SandboxedEnvironment__objR8R9tfmt((s2/usr/lib/python2.7/site-packages/jinja2/sandbox.pyRs   (RERFRGRWt sandboxedRxR tsubtmulttruedivtfloordivtpowtmodR{tpostnegR~t frozensettintercepted_binopstintercepted_unopsRyR:RRRRRRRRR(((s2/usr/lib/python2.7/site-packages/jinja2/sandbox.pyRrs4                  tImmutableSandboxedEnvironmentcBseZdZdZRS(sWorks 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. cCs*tj||||stSt|| S(N(RrRRoRq(R7RPRlR((s2/usr/lib/python2.7/site-packages/jinja2/sandbox.pyRs(RERFRGR(((s2/usr/lib/python2.7/site-packages/jinja2/sandbox.pyRs(tformatter_field_name_splitcCs |jS(N(t_formatter_field_name_split(t field_name((s2/usr/lib/python2.7/site-packages/jinja2/sandbox.pyRstSandboxedFormatterMixincBseZdZdZRS(cCs ||_dS(N(t_env(R7tenv((s2/usr/lib/python2.7/site-packages/jinja2/sandbox.pyR:sc Cs{t|\}}|j|||}xG|D]?\}}|rX|jj||}q.|jj||}q.W||fS(N(Rt get_valueRRR( R7RR8R9tfirsttrestRPtis_attrti((s2/usr/lib/python2.7/site-packages/jinja2/sandbox.pyt get_fields(RERFR:R(((s2/usr/lib/python2.7/site-packages/jinja2/sandbox.pyRs RcBseZdZRS(cCs!tj||tj|dS(N(RR:R(R7R((s2/usr/lib/python2.7/site-packages/jinja2/sandbox.pyR:s(RERFR:(((s2/usr/lib/python2.7/site-packages/jinja2/sandbox.pyRsRcBseZdZRS(cCs$tj||tj||dS(N(RR:R(R7RR((s2/usr/lib/python2.7/site-packages/jinja2/sandbox.pyR:s(RERFR:(((s2/usr/lib/python2.7/site-packages/jinja2/sandbox.pyRs(;RGRJRxt collectionsRtjinja2.environmentRtjinja2.exceptionsRtjinja2._compatRRt jinja2.utilsRt markupsafeRtstringRRStsetR`RaRgRiRjtwarningstfilterwarningstDeprecationWarningRt_mutable_set_typestdictt_mutable_mapping_typestlistt_mutable_sequence_typesRRRt ImportErrortsetsRRRRRRnR3RQRVRZRmRqRrRt_stringRtobjectRRR(((s2/usr/lib/python2.7/site-packages/jinja2/sandbox.pyts              $