
    fW                     0   d Z ddlZddlmZmZmZ ddlmZmZm	Z	m
Z
mZ ddlmZ dZdZ	 ddlmZ dd	lmZ d
ZdZdgZ G d de      Zd Zy# e$ rD 	 ddlmZ dZd
Z ej*                  ded       n # e$ r  ej*                  ded       Y nw xY wY Zw xY w)zD
NBConvert Preprocessor for sanitizing HTML rendering of notebooks.
    N)ALLOWED_ATTRIBUTESALLOWED_TAGSclean)AnyBoolListSetUnicode   )PreprocessorF)ALLOWED_CSS_PROPERTIES)CSSSanitizerT)ALLOWED_STYLESzFSupport for bleach <5 will be removed in a future version of nbconvert   )
stacklevelz[The installed bleach/tinycss2 do not provide CSS sanitization, please upgrade to bleach >=5SanitizeHTMLc                       e Zd ZdZ eded      Z e e       de	d      Z
 e e       ded      Z eddd      Z eddd	      Z edh d
d      Z edddhd      Zd Zd Zd Zy)r   z A preprocessor to sanitize html.TzAllowed HTML tag attributes)configdefault_valuehelpzList of HTML tags to allowz,Allowed CSS styles if <style> tag is allowedFz:If True, remove unsafe markup entirely instead of escapingz)If True, strip comments from escaped HTML>   	image/png
image/jpeg
text/latex
text/plainapplication/jsonmetadataz4Cell output mimetypes to render without modificationz	text/htmlztext/markdownz8Cell output types to display after escaping with Bleach.c                 6   |j                   dk(  r$| j                  |j                        |_        ||fS |j                   dk(  r$| j                  |j                        |_        ||fS |j                   dk(  r$| j                  |j                        |_        ||fS y)a  
        Sanitize potentially-dangerous contents of the cell.

        Cell Types:
          raw:
            Sanitize literal HTML
          markdown:
            Sanitize literal HTML
          code:
            Sanitize outputs that could result in code execution
        rawmarkdowncodeN)	cell_typesanitize_html_tagssourcesanitize_code_outputsoutputs)selfcell	resources
cell_indexs       [/var/www/cvtools/html/venv/lib/python3.12/site-packages/nbconvert/preprocessors/sanitize.pypreprocess_cellzSanitizeHTML.preprocess_cellf   s     >>U" 11$++>DK?">>Z'11$++>DK?">>V#55dllCDL?"    c                 ^   |D ]  }|d   dv r|j                   }g }|D ]d  }|| j                  v r|| j                  v r4| j                  j	                  d|       | j                  ||         ||<   T|j                  |       f |D ]!  }| j                  j	                  d|       ||= #  |S )z
        Sanitize code cell outputs.

        Removes 'text/javascript' fields from display_data outputs, and
        runs `sanitize_html_tags` over 'text/html'.
        output_type)streamerrorzSanitizing %szRemoving %s)datasafe_output_keyssanitized_output_typesloginfor"   append)r&   r%   outputr1   	to_removekeys         r*   r$   z"SanitizeHTML.sanitize_code_outputs   s      	Fm$(;;;;DI 	*$///$555HHMM/37 $ 7 7S	 BDI $$S)	* ! mS1I!	& r,   c                    | j                   | j                  | j                  | j                  d}t        r)t        | j                        }|j                  |       n"t        r|j                  | j                         t        |fi |S )z=
        Sanitize a string containing raw HTML tags.
        )tags
attributesstripstrip_commentsallowed_css_properties)css_sanitizer)styles)
r;   r<   r=   r>   _USE_BLEACH_CSS_SANITIZERr   rB   update_USE_BLEACH_STYLESr   )r&   html_strkwargsrA   s       r*   r"   zSanitizeHTML.sanitize_html_tags   so    
 II//ZZ"11	
 %(LMMMM6MMM-X(((r,   N)__name__
__module____qualname____doc__r   r   r<   r   r
   r   r;   r   rB   r   r=   r>   r	   r2   r3   r+   r$   r"    r,   r*   r   r   0   s    * (*J
 	")	D 	$;	F IE
 8N 
 D !
 H48)r,   c                  0    t         rt        t              S y )Nr?   )rC   r   r   rL   r,   r*   _get_default_css_sanitizerrN      s     >BBr,   )rK   warningsbleachr   r   r   	traitletsr   r   r   r	   r
   baser   rC   rE   bleach.css_sanitizerr   r   r   ImportErrorwarnDeprecationWarningUserWarning__all__r   rN   rL   r,   r*   <module>rY      s     : : 3 3 !  
M1 $. 
})< })@s  

)$)!!T	
  
+		


s5   A BA21B2BBBBB