
    MhW                     2   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nH# e$ r@ 	 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 nw xY wdgZ G d de          Zd ZdS )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dS )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                    |j         dk    r#|                     |j                  |_        ||fS |j         dk    r#|                     |j                  |_        ||fS |j         dk    r#|                     |j                  |_        ||fS dS )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/html/test/jupyter/venv/lib/python3.11/site-packages/nbconvert/preprocessors/sanitize.pypreprocess_cellzSanitizeHTML.preprocess_cellf   s     >U"" 11$+>>DK?">Z''11$+>>DK?">V##55dlCCDL?"t    c                 L   |D ]}|d         dv r|j         }g }|D ]d}|| j        v r|| j        v r:| j                            d|           |                     ||                   ||<   O|                    |           e|D ] }| 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HMM/3777 $ 7 7S	 B BDII $$S))))   mS111II r,   c                     | j         | j        | j        | j        d}t          r,t          | j                  }|                    |           n"t          r|                    | 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   s    
 I/Z"1	
 
 % 	.(LLLMMMM666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
 4		")	  D T		$;	  F DI  E
 T8  N s
 
 
 D   !S
 H    4  8) ) ) ) )r,   c                  >    t           rt          t                    S d S )Nr?   )rC   r   r   rL   r,   r*   _get_default_css_sanitizerrN      s!      C>BBBB4r,   )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 3 3 3 3 3 3 3 3 3 3 3 3      !  
MMMMMM111111 $ 
 
 

))))))$)!!T	
 	
 	
 	
 	
  
 
 
+		
 	
 	
 	
 	
 	


, 
}) }) }) }) })< }) }) })@    s3   ; B AB A:7B 9A::B ?B 