
    R?g00                     2   S SK r S SKrS SKJrJrJrJrJrJrJ	r	J
r
JrJr  S SKJr  S SKJrJrJrJrJr  / S0 S4PS0 S4PS	0 S
4PS0 S4PS0 S4PS0 S4PS0 S4PS0 S4PS0 S4PS0 S4PS0 S4PS0 S4PS0 S4PS0 S 4PS!0 S"4PS#0 S$4PS%0 S&4PS'S(S)S*/0S+4PS,S(S*/0S-4PS.0 S/4PS00 S14PS20 S34PS40 S54PS6S(S)S7/0S84PS90 S:4PS;0 S<4PS=0 S>4PS=S?S@0S=4PSAS@S@SB.SC4PSDSES@0SF4PSG0 SH4PSGS(SI/0SJ4PSKSLSM0SN4PSOSLSP 0SQ4PSKSLSR 0SN4Pr " SS ST\ R,                  5      rg)U    N)
utf8xhtml_escapexhtml_unescape
url_escapeurl_unescape
to_unicodejson_decodejson_encodesqueezerecursive_unicode)unicode_type)ListTupleUnionDictAnyzhello http://world.com/!z8hello <a href="http://world.com/">http://world.com/</a>!z0hello http://world.com/with?param=true&stuff=yeszqhello <a href="http://world.com/with?param=true&amp;stuff=yes">http://world.com/with?param=true&amp;stuff=yes</a>z>http://url.com/w(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaz]<a href="http://url.com/w">http://url.com/w</a>(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaz>http://url.com/withmany.......................................zd<a href="http://url.com/withmany">http://url.com/withmany</a>.......................................z;http://url.com/withmany((((((((((((((((((((((((((((((((((a)za<a href="http://url.com/withmany">http://url.com/withmany</a>((((((((((((((((((((((((((((((((((a)zhttp://foo.com/blah_blahz?<a href="http://foo.com/blah_blah">http://foo.com/blah_blah</a>zhttp://foo.com/blah_blah/zA<a href="http://foo.com/blah_blah/">http://foo.com/blah_blah/</a>z)(Something like http://foo.com/blah_blah)zP(Something like <a href="http://foo.com/blah_blah">http://foo.com/blah_blah</a>)z$http://foo.com/blah_blah_(wikipedia)zW<a href="http://foo.com/blah_blah_(wikipedia)">http://foo.com/blah_blah_(wikipedia)</a>z+http://foo.com/blah_(blah)_(wikipedia)_blahze<a href="http://foo.com/blah_(blah)_(wikipedia)_blah">http://foo.com/blah_(blah)_(wikipedia)_blah</a>z5(Something like http://foo.com/blah_blah_(wikipedia))zh(Something like <a href="http://foo.com/blah_blah_(wikipedia)">http://foo.com/blah_blah_(wikipedia)</a>)zhttp://foo.com/blah_blah.z@<a href="http://foo.com/blah_blah">http://foo.com/blah_blah</a>.zhttp://foo.com/blah_blah/.zB<a href="http://foo.com/blah_blah/">http://foo.com/blah_blah/</a>.z<http://foo.com/blah_blah>zG&lt;<a href="http://foo.com/blah_blah">http://foo.com/blah_blah</a>&gt;z<http://foo.com/blah_blah/>zI&lt;<a href="http://foo.com/blah_blah/">http://foo.com/blah_blah/</a>&gt;zhttp://foo.com/blah_blah,z@<a href="http://foo.com/blah_blah">http://foo.com/blah_blah</a>,z&http://www.example.com/wpstyle/?p=364.zZ<a href="http://www.example.com/wpstyle/?p=364">http://www.example.com/wpstyle/?p=364</a>.zrdar://1234permitted_protocolshttprdarz%<a href="rdar://1234">rdar://1234</a>z
rdar:/1234z#<a href="rdar:/1234">rdar:/1234</a>z'http://userid:password@example.com:8080z]<a href="http://userid:password@example.com:8080">http://userid:password@example.com:8080</a>zhttp://userid@example.comzA<a href="http://userid@example.com">http://userid@example.com</a>zhttp://userid@example.com:8080zK<a href="http://userid@example.com:8080">http://userid@example.com:8080</a>z"http://userid:password@example.comzS<a href="http://userid:password@example.com">http://userid:password@example.com</a>zFmessage://%3c330e7f8409726r6a4ba78dkf1fd71420c1bf6ff@mail.gmail.com%3emessagez<a href="message://%3c330e7f8409726r6a4ba78dkf1fd71420c1bf6ff@mail.gmail.com%3e">message://%3c330e7f8409726r6a4ba78dkf1fd71420c1bf6ff@mail.gmail.com%3e</a>u   http://➡.ws/䨹u1   <a href="http://➡.ws/䨹">http://➡.ws/䨹</a>z<tag>http://example.com</tag>zJ&lt;tag&gt;<a href="http://example.com">http://example.com</a>&lt;/tag&gt;zJust a www.example.com link.zAJust a <a href="http://www.example.com">www.example.com</a> link.require_protocolTz:A http://reallylong.com/link/that/exceedsthelenglimit.html)r   shortenzA <a href="http://reallylong.com/link/that/exceedsthelenglimit.html" title="http://reallylong.com/link/that/exceedsthelenglimit.html">http://reallylong.com/link...</a>z6A http://reallylongdomainnamethatwillbetoolong.com/hi!r   zA <a href="http://reallylongdomainnamethatwillbetoolong.com/hi" title="http://reallylongdomainnamethatwillbetoolong.com/hi">http://reallylongdomainnametha...</a>!z/A file:///passwords.txt and http://web.com linkzLA file:///passwords.txt and <a href="http://web.com">http://web.com</a> linkfilezSA <a href="file:///passwords.txt">file:///passwords.txt</a> and http://web.com linkzwww.external-link.comextra_paramsrel="nofollow" class="external"z`<a href="http://www.external-link.com" rel="nofollow" class="external">www.external-link.com</a>z;www.external-link.com and www.internal-link.com/blogs extrac                 6    U R                  S5      (       a  S$ S$ )Nzhttp://www.internal-link.comzclass="internal"r   )
startswithhrefs    :/usr/lib/python3/dist-packages/tornado/test/escape_test.py<lambda>r!      s$    ??#ABB # 767    z<a href="http://www.external-link.com" rel="nofollow" class="external">www.external-link.com</a> and <a href="http://www.internal-link.com/blogs" class="internal">www.internal-link.com/blogs</a> extrac                     g)Nz%    rel="nofollow" class="external"   r   s    r    r!   r!      s    &Mr"   c                   V    \ rS rSrS rS rS rS rS rS r	S r
S	 rS
 rS rS rSrg)EscapeTestCase   c                     [          H8  u  pn[        R                  R                  " U40 UD6nU R	                  XC5        M:     g )N)linkify_teststornadoescapelinkifyassertEqual)selftextkwargshtmllinkeds        r    test_linkifyEscapeTestCase.test_linkify   s8    "/D$^^++D;F;FV* #0r"   c           	          / SQnU H_  u  p#U R                  [        [        U5      5      [        U5      5        U R                  [        U5      [        [        U5      5      5        Ma     g )N)z<foo>z&lt;foo&gt;r6   )s   <foo>s   &lt;foo&gt;)z<>&"'z&lt;&gt;&amp;&quot;&#x27;)z&amp;z	&amp;amp;)u   <é>u
   &lt;é&gt;)s   <é>s
   &lt;é&gt;)r-   r   r   r   r.   tests	unescapedescapeds       r    test_xhtml_escape EscapeTestCase.test_xhtml_escape   sT    
 #(IT,y"9:DMJT)_d>'3J.KL #(r"   c                 X    / SQnU H   u  p#U R                  U[        U5      5        M"     g )N))zfoo&#32;barfoo bar)zfoo&#x20;barr>   )zfoo&#X20;barr>   )zfoo&#xabc;baru	   foo઼bar)foo&#xyz;barr?   )	foo&#;barr@   )
foo&#x;barrA   )r-   r   )r.   r8   r:   r9   s       r    test_xhtml_unescape_numeric*EscapeTestCase.test_xhtml_unescape_numeric   s-    
 #(GYw(?@ #(r"   c                     SR                  S5      S4SR                  S5      S4S/nU H   u  p#U R                  [        U5      U5        M"     g )N   ér   %C3%A9latin1z%E9)rE   rF   )encoder-   r   r7   s       r    test_url_escape_unicode&EscapeTestCase.test_url_escape_unicode   sT     __V$h/__X&. 
 #(IZ	2G< #(r"   c                     SSS[        S5      S 4/nU HP  u  p#nU R                  [        [        U5      U5      U5        U R                  [        [        U5      U5      U5        MR     g )N)rF   rE   r   )rF   u   Ã©rG   rF   rE   )r   r-   r   r   )r.   r8   r:   r9   encodings        r    test_url_unescape_unicode(EscapeTestCase.test_url_unescape_unicode  sg    (0tH~t,

 -2(G \*W*=xH)T\$w-BIN -2r"   c                 r   SnSnSnU R                  [        U5      U5        U R                  [        USS9U5        U R                  [        U5      U5        U R                  [        USS9U5        U R                  [        US S9[        U5      5        U R                  [        US SS9[        U5      5        g )Nz+ #%z
%2B+%23%25z%2B%20%23%25F)plus)rL   )rL   rP   )r-   r   r   r   )r.   r9   plus_escapedr:   s       r    test_url_escape_quote_plus)EscapeTestCase.test_url_escape_quote_plus  s    	# I.=IE:GDl3Y?gE:IFlTBDOT4e<d9o	
r"   c                     U R                  [        [        S5      5      [        5        U R                  [        [        S5      5      [        5        g )Nfoo)r-   typer   strr   r.   s    r    test_escape_return_types'EscapeTestCase.test_escape_return_types  s8     	l512C8l512LAr"   c                     U R                  [        S5      S5        U R                  [        S5      S5        U R                  [        [        S5      5      S5        g )Ns   "foo"rU   z"foo"u   "é"rE   )r-   r	   r   rX   s    r    test_json_decodeEscapeTestCase.test_json_decode"  sJ     	X.6W-u5 	T*%56Ar"   c           	          U R                  [        [        S5      5      S5        [        [        L aI  U R                  [        [        [        S5      5      5      S5        U R                  [        [        S5        g g )NrE      )r-   r	   r
   bytesrW   r   assertRaisesUnicodeDecodeErrorrX   s    r    test_json_encodeEscapeTestCase.test_json_encode+  s[     	[%:;XFC<[T(^)DExP0+wG r"   c                 :    U R                  [        S5      S5        g )Nz&sequences     of    whitespace   charszsequences of whitespace chars)r-   r   rX   s    r    test_squeezeEscapeTestCase.test_squeeze4  s    <=+	
r"   c                    SS0SS/SSS.nU R                  [        US   5      SS05        U R                  [        US   5      SS/5        U R                  [        US	   5      S
5        U R                  [        US   5      S5        g )N   foo   bar)ri   rj   )dictlisttupler`   rk   rU   barrl   rm   )rU   rn   r`   )r-   r   )r.   r8   s     r    test_recursive_unicode%EscapeTestCase.test_recursive_unicode:  s    V$V$%	
 	*5=9E5>J*5=9E5>J*5>:NK*5>:EBr"   r$   N)__name__
__module____qualname____firstlineno__r3   r;   rB   rI   rM   rR   rY   r\   rc   rf   ro   __static_attributes__r$   r"   r    r&   r&      s@    +
MA	=O
BBH

Cr"   r&   )unittestr*   tornado.escaper   r   r   r   r   r   r	   r
   r   r   tornado.utilr   typingr   r   r   r   r   r)   TestCaser&   r$   r"   r    <module>r{      s       & 0 0 	#
B 	;
{ 	I
g( 	I
n'2 	F
k1@ 	#
I?J 	$
KIT 	4
ZS^ 	/
a]h 	6
ogr 	@
rq| 	$
J{F 	%
LEP 	%
QOZ 	&
SYd 	$
Jcn 	1
dmx 		 01/wB 		)-AL 	2
gKV 	$
KU` 	)
U_j 	-
]it 	Q	 34	Us@ 	"
GJ 	(
TIT 	'
KS^ 	'	T"&]h 	E!d3	ngt 	A	D	ns@ 	:
VJ 	:	)]IT 	 	:;jS^ 	F 	
	s]v 	 	MNjuDnCX&& nCr"   