o
    –�ži	  ã                   @   s"   d dl mZ G dd„ dejƒZdS )é    )Úmodelsc                       sb   e Zd ZdZdZdZ‡ fdd„Z‡ fdd„Z‡ fdd	„Zd‡ fdd„	Z	‡ fdd„Z
dd„ Z‡  ZS )ÚIrQwebz§Add ``raise_on_forbidden_code_for_model`` option for qweb.

    When this option is activated, only a whitelist of expressions
    is allowed for the given model.
    zir.qweb)Úoutzinner-contentÚattztag-openz	tag-closec                    s   t ƒ  ¡ dg S )NÚ!raise_on_forbidden_code_for_model)ÚsuperÚ_get_template_cache_keys)Úself©Ú	__class__© ú;/home/minischoggi19/odoo/odoo/addons/mail/models/ir_qweb.pyr      s   zIrQweb._get_template_cache_keysc                    s,   d|v r|| j vrtdƒ‚tƒ  ||||¡S ©Nr   ú6This directive is not allowed for this rendering mode.)Úallowed_directivesÚPermissionErrorr   Ú_compile_directive)r	   ÚelÚcompile_contextÚ	directiveÚlevelr
   r   r   r      s   
zIrQweb._compile_directivec                    s2   d|v rt |jƒh d£ rtdƒ‚tƒ  |||¡S )Nr   >   út-inner-contentút-outú
t-tag-openút-tag-closer   )ÚsetÚattribr   r   Ú_compile_directive_att©r	   r   r   r   r
   r   r   r   "   s   zIrQweb._compile_directive_attFc                    s8   | j j d¡}|d ur|  ||¡stdƒ‚tƒ  ||¡S r   )ÚenvÚcontextÚgetÚ_is_expression_allowedr   r   Ú_compile_expr)r	   ÚexprÚraise_on_missingÚmodelr
   r   r   r#   (   s   zIrQweb._compile_exprc                    sF   d|v rt |ƒdkrtdƒ‚t|jƒh d£ rtdƒ‚tƒ  |||¡S )Nr   r   zNo child allowed for t-out.>   r   r   r   z%No other attribute allowed for t-out.)Úlenr   r   r   r   Ú_compile_directive_outr   r
   r   r   r(   .   s   zIrQweb._compile_directive_outc                 C   s   |o|  ¡ | j|  ¡ v S )N)Ústripr   Úmail_allowed_qweb_expressions)r	   Ú
expressionr&   r   r   r   r"   6   s   zIrQweb._is_expression_allowed)F)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú_inheritr   r   r   r   r#   r(   r"   Ú__classcell__r   r   r
   r   r      s    r   N)Úodoor   ÚAbstractModelr   r   r   r   r   Ú<module>   s   