
    Mh                     >   d Z ddlZddlZddlZddlmZmZ 	 ddlmZ ej	        
                    d          Zej	        
                    d          Zedk    oedk    Zn# e$ r dZY nw xY wej                            e d	           G d
 de                      ZdS )a  This file contains test cases reported by third parties using
fuzzing tools, primarily from Google's oss-fuzz project. Some of these
represent real problems with Beautiful Soup, but many are problems in
libraries that Beautiful Soup depends on, and many of the test cases
represent different ways of triggering the same problem.

Grouping these test cases together makes it easy to see which test
cases represent the same problem, and puts the test cases in close
proximity to code that can trigger the problems.
    N)BeautifulSoupParserRejectedMarkup)SelectorSyntaxErrorlxmlhtml5libFz/Prerequisites for fuzz tests are not installed.reasonc                   |   e Zd ZdZdeddfdZej                            dddg          d             Z	ej                            dg d	          d
             Z
ej                            dg d          d             Zej                            dddg          d             Zej                            d          ej                            dg d          d                         Zej                            d          ej                            ddg          d                         ZdedefdZdS )TestFuzzz	.testcasefilenamereturnNc                 :   |                      |          }g d}	 t          |d                   t          |          z  }n# t          $ r Y d S w xY w|dd         |dd          }}	 t	          |dd          ||                   }n# t
          $ r Y d S t          $ r Y d S w xY wt          |                    d                     	 |j        	                    |
                    dd                     n# t          $ r Y d S w xY w|                                 d S )	N)zlxml-xmlr   html.parserr   r      
   )featuresTzutf-8replace)_TestFuzz__markupintlen
ValueErrorr   r   listfind_allcssselectdecoder   prettify)selfr   dataparsersidxcss_selectorsoups          S/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/bs4/tests/test_fuzz.pyfuzz_test_with_csszTestFuzz.fuzz_test_with_css-   sW   }}X&&AAA	d1g,,W-CC 	 	 	FF	 "!B$Zbccd	 abbGCLAAADD# 	 	 	FF 	 	 	FF	 	T]]4  !!!	HOOL//CCDDDD" 	 	 	FF	s;   %A 
AA'B 
B!	B! B!.C6 6
DDz:clusterfuzz-testcase-minimized-bs4_fuzzer-5703933063462912z.crash-ffbdfa8a2b26f13537b68d3794b0478a4090ee4ac                     |                      |          }t          j        t                    5  t	          |d           d d d            d S # 1 swxY w Y   d S Nr   )r   pytestraisesr   r   r   r   markups      r$   test_rejected_markupzTestFuzz.test_rejected_markupH   s     x((]/00 	1 	1&-000	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1s   AAA)z:clusterfuzz-testcase-minimized-bs4_fuzzer-5984173902397440z:clusterfuzz-testcase-minimized-bs4_fuzzer-5167584867909632z:clusterfuzz-testcase-minimized-bs4_fuzzer-6124268085182464z:clusterfuzz-testcase-minimized-bs4_fuzzer-6450958476902400c                 t    |                      |          }t          |d                                           d S r'   )r   r   encoder*   s      r$   'test_deeply_nested_document_without_cssz0TestFuzz.test_deeply_nested_document_without_css[   s7     x((fm,,3355555    )z:clusterfuzz-testcase-minimized-bs4_fuzzer-5000587759190016z:clusterfuzz-testcase-minimized-bs4_fuzzer-5375146639360000z:clusterfuzz-testcase-minimized-bs4_fuzzer-5492400320282624c                 0    |                      |           d S Nr%   r   r   s     r$   test_deeply_nested_documentz$TestFuzz.test_deeply_nested_documento        	)))))r0   z:clusterfuzz-testcase-minimized-bs4_fuzzer-4670634698080256z:clusterfuzz-testcase-minimized-bs4_fuzzer-5270998950477824c                 0    |                      |           d S r2   r3   r4   s     r$   test_soupsieve_errorszTestFuzz.test_soupsieve_errorsz   s     	)))))r0   zhtml5lib-specific problemsr   )z:clusterfuzz-testcase-minimized-bs4_fuzzer-4818336571064320z:clusterfuzz-testcase-minimized-bs4_fuzzer-4999465949331456z:clusterfuzz-testcase-minimized-bs4_fuzzer-5843991618256896z:clusterfuzz-testcase-minimized-bs4_fuzzer-6241471367348224z:clusterfuzz-testcase-minimized-bs4_fuzzer-6600557255327744z.crash-0d306a50c8ed8bcd0785b67000fcd5dea1d33f08c                     |                      |          }t          t          |d                                                     d S )Nr   )r   printr   r.   r*   s      r$   &test_html5lib_parse_errors_without_cssz/TestFuzz.test_html5lib_parse_errors_without_css   s?    & x((mFJ//668899999r0   z:clusterfuzz-testcase-minimized-bs4_fuzzer-6306874195312640c                 0    |                      |           d S r2   r3   r4   s     r$   test_html5lib_parse_errorsz#TestFuzz.test_html5lib_parse_errors   r6   r0   c                 $   |                     | j                  s
|| j        z  }t          j                            t
                    d         }t          j                            |d|          }t          |d                                          S )Nr   fuzzrb)	endswithTESTCASE_SUFFIXospathsplit__file__joinopenread)r   r   this_dirrD   s       r$   __markupzTestFuzz.__markup   ss      !566 	-,,H7==**1-w||Hfh77D$$$&&&r0   )__name__
__module____qualname__rB   strr%   r(   markparametrizer,   r/   r5   r8   skipr;   r=   bytesr    r0   r$   r   r      s        "O3 4    6 [H<	
 1 1 1 [	
 	
 	
 6 6 6 [	
 	
 	
 * * * [HH	
 * * * [9::[	
 	
 	
 ": :#  ;:$: [9::[ I	
 * *  ;:*' ' ' ' ' ' ' 'r0   r   )__doc__rC   	importlibr(   bs4r   r   soupsieve.utilr   util	find_spechas_lxmlhas_html5libfully_fuzzableImportErrorrP   skipifobjectr   rT   r0   r$   <module>ra      s?  	 	 
			            
222222~''//H>++J77L%>,$*>NN   NNN P   U' U' U' U' U'v U' U' U' U' U's   AA A)(A)