
[c        &   @` s  d  d l  m Z m Z m Z d  d l Z d  d l m Z m Z m Z m	 Z	 m
 Z
 m Z m Z m Z m Z m Z d  d l m Z d  d l m Z d i  d f d i  d	 f d
 i  d f d i  d f d i  d f d i  d f d i  d f d i  d f d i  d f d i  d f d i  d f d i  d f d i  d f d  i  d! f d" i  d# f d$ i  d% f d& i  d' f d( i d) d* g d+ 6d, f d- i d* g d+ 6d. f d/ i  d0 f d1 i  d2 f d3 i  d4 f d5 i  d6 f d7 i d) d8 g d+ 6d9 f d: i  d; f d< i  d= f d> i  d? f d> i e d@ 6dA f dB i e d@ 6e dC 6dD f dE i e dC 6dF f dG i  dH f dG i dI g d+ 6dJ f dK i dL dM 6dN f dO i dP   dM 6dQ f dK i dR   dM 6dN f g# Z dS e j f dT     YZ d S(U   i    (   t   absolute_importt   divisiont   print_functionN(
   t   utf8t   xhtml_escapet   xhtml_unescapet
   url_escapet   url_unescapet
   to_unicodet   json_decodet   json_encodet   squeezet   recursive_unicode(   t   unicode_type(   t   unittests   hello http://world.com/!u8   hello <a href="http://world.com/">http://world.com/</a>!s0   hello http://world.com/with?param=true&stuff=yesuq   hello <a href="http://world.com/with?param=true&amp;stuff=yes">http://world.com/with?param=true&amp;stuff=yes</a>s>   http://url.com/w(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaau]   <a href="http://url.com/w">http://url.com/w</a>(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaas>   http://url.com/withmany.......................................ud   <a href="http://url.com/withmany">http://url.com/withmany</a>.......................................s;   http://url.com/withmany((((((((((((((((((((((((((((((((((a)ua   <a href="http://url.com/withmany">http://url.com/withmany</a>((((((((((((((((((((((((((((((((((a)s   http://foo.com/blah_blahu?   <a href="http://foo.com/blah_blah">http://foo.com/blah_blah</a>s   http://foo.com/blah_blah/uA   <a href="http://foo.com/blah_blah/">http://foo.com/blah_blah/</a>s)   (Something like http://foo.com/blah_blah)uP   (Something like <a href="http://foo.com/blah_blah">http://foo.com/blah_blah</a>)s$   http://foo.com/blah_blah_(wikipedia)uW   <a href="http://foo.com/blah_blah_(wikipedia)">http://foo.com/blah_blah_(wikipedia)</a>s+   http://foo.com/blah_(blah)_(wikipedia)_blahue   <a href="http://foo.com/blah_(blah)_(wikipedia)_blah">http://foo.com/blah_(blah)_(wikipedia)_blah</a>s5   (Something like http://foo.com/blah_blah_(wikipedia))uh   (Something like <a href="http://foo.com/blah_blah_(wikipedia)">http://foo.com/blah_blah_(wikipedia)</a>)s   http://foo.com/blah_blah.u@   <a href="http://foo.com/blah_blah">http://foo.com/blah_blah</a>.s   http://foo.com/blah_blah/.uB   <a href="http://foo.com/blah_blah/">http://foo.com/blah_blah/</a>.s   <http://foo.com/blah_blah>uG   &lt;<a href="http://foo.com/blah_blah">http://foo.com/blah_blah</a>&gt;s   <http://foo.com/blah_blah/>uI   &lt;<a href="http://foo.com/blah_blah/">http://foo.com/blah_blah/</a>&gt;s   http://foo.com/blah_blah,u@   <a href="http://foo.com/blah_blah">http://foo.com/blah_blah</a>,s&   http://www.example.com/wpstyle/?p=364.uZ   <a href="http://www.example.com/wpstyle/?p=364">http://www.example.com/wpstyle/?p=364</a>.s   rdar://1234t   httpt   rdart   permitted_protocolsu%   <a href="rdar://1234">rdar://1234</a>s
   rdar:/1234u#   <a href="rdar:/1234">rdar:/1234</a>s'   http://userid:password@example.com:8080u]   <a href="http://userid:password@example.com:8080">http://userid:password@example.com:8080</a>s   http://userid@example.comuA   <a href="http://userid@example.com">http://userid@example.com</a>s   http://userid@example.com:8080uK   <a href="http://userid@example.com:8080">http://userid@example.com:8080</a>s"   http://userid:password@example.comuS   <a href="http://userid:password@example.com">http://userid:password@example.com</a>sF   message://%3c330e7f8409726r6a4ba78dkf1fd71420c1bf6ff@mail.gmail.com%3et   messageu   <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>s   <tag>http://example.com</tag>uJ   &lt;tag&gt;<a href="http://example.com">http://example.com</a>&lt;/tag&gt;s   Just a www.example.com link.uA   Just a <a href="http://www.example.com">www.example.com</a> link.t   require_protocolu   Just a www.example.com link.s:   A http://reallylong.com/link/that/exceedsthelenglimit.htmlt   shortenu   A <a href="http://reallylong.com/link/that/exceedsthelenglimit.html" title="http://reallylong.com/link/that/exceedsthelenglimit.html">http://reallylong.com/link...</a>s6   A http://reallylongdomainnamethatwillbetoolong.com/hi!u   A <a href="http://reallylongdomainnamethatwillbetoolong.com/hi" title="http://reallylongdomainnamethatwillbetoolong.com/hi">http://reallylongdomainnametha...</a>!s/   A file:///passwords.txt and http://web.com linkuL   A file:///passwords.txt and <a href="http://web.com">http://web.com</a> linkt   fileuS   A <a href="file:///passwords.txt">file:///passwords.txt</a> and http://web.com links   www.external-link.coms   rel="nofollow" class="external"t   extra_paramsu`   <a href="http://www.external-link.com" rel="nofollow" class="external">www.external-link.com</a>s;   www.external-link.com and www.internal-link.com/blogs extrac         C` s   |  j  d  r d Sd S(   Ns   http://www.internal-link.coms   class="internal"s   rel="nofollow" class="external"(   t
   startswith(   t   href(    (    s7   lib/python2.7/site-packages/tornado/test/escape_test.pyt   <lambda>   s    u   <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         C` s   d S(   Ns%       rel="nofollow" class="external"  (    (   R   (    (    s7   lib/python2.7/site-packages/tornado/test/escape_test.pyR      s    t   EscapeTestCasec           B` sk   e  Z d    Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z d
   Z RS(   c         C` sC   x< t  D]4 \ } } } t j j | |  } |  j | |  q Wd  S(   N(   t   linkify_testst   tornadot   escapet   linkifyt   assertEqual(   t   selft   textt   kwargst   htmlt   linked(    (    s7   lib/python2.7/site-packages/tornado/test/escape_test.pyt   test_linkify   s    c         C` sz   d d d d d d d g } xX | D]P \ } } |  j  t t |   t |   |  j  t |  t t |    q" Wd  S(   Ns   <foo>s   &lt;foo&gt;u   <foo>u   &lt;foo&gt;s   <>&"'s   &lt;&gt;&amp;&quot;&#39;s   &amp;s	   &amp;amp;u   <é>u
   &lt;é&gt;s   <é>s
   &lt;é&gt;(   s   <foo>s   &lt;foo&gt;(   u   <foo>u   &lt;foo&gt;(   s   <foo>s   &lt;foo&gt;(   s   <>&"'s   &lt;&gt;&amp;&quot;&#39;(   s   &amp;s	   &amp;amp;(   u   <é>u
   &lt;é&gt;(   s   <é>s
   &lt;é&gt;(   R   R   R   R   (   R    t   testst	   unescapedt   escaped(    (    s7   lib/python2.7/site-packages/tornado/test/escape_test.pyt   test_xhtml_escape   s    	"c         C` sL   d
 d d d d d d g } x* | D]" \ } } |  j  | t |   q" Wd  S(   Ns   foo&#32;bars   foo bars   foo&#x20;bars   foo&#X20;bars   foo&#xabc;baru	   foo઼bars   foo&#xyz;bars	   foo&#;bars
   foo&#x;bar(   s   foo&#32;bars   foo bar(   s   foo&#x20;bars   foo bar(   s   foo&#X20;bars   foo bar(   s   foo&#xabc;baru	   foo઼bar(   s   foo&#xyz;bars   foo&#xyz;bar(   s	   foo&#;bars	   foo&#;bar(   s
   foo&#x;bars
   foo&#x;bar(   R   R   (   R    R&   R(   R'   (    (    s7   lib/python2.7/site-packages/tornado/test/escape_test.pyt   test_xhtml_unescape_numeric   s    	c         C` s^   d j  d  d f d j  d  d f d g } x* | D]" \ } } |  j t |  |  q4 Wd  S(   Nu   éR   s   %C3%A9t   latin1s   %E9(   u   és   %C3%A9(   t   encodeR   R   (   R    R&   R'   R(   (    (    s7   lib/python2.7/site-packages/tornado/test/escape_test.pyt   test_url_escape_unicode   s
    	c         C` sz   d d d t  d  d  f g } xU | D]M \ } } } |  j t t |  |  |  |  j t t  |  |  |  q% Wd  S(   Ns   %C3%A9u   éR   u   Ã©R+   (   s   %C3%A9u   éR   (   s   %C3%A9u   Ã©R+   (   R   t   NoneR   R   R   (   R    R&   R(   R'   t   encoding(    (    s7   lib/python2.7/site-packages/tornado/test/escape_test.pyt   test_url_unescape_unicode   s    c         C` s   d } d } d } |  j  t |  |  |  j  t | d t |  |  j  t |  |  |  j  t | d t |  |  j  t | d d  t |   |  j  t | d d  d t t |   d  S(   Ns   + #%s
   %2B+%23%25s   %2B%20%23%25t   plusR/   (   R   R   t   FalseR   R.   R   (   R    R'   t   plus_escapedR(   (    (    s7   lib/python2.7/site-packages/tornado/test/escape_test.pyt   test_url_escape_quote_plus   s    c         C` s<   |  j  t t d   t  |  j  t t d   t  d  S(   Nt   foou   foo(   R   t   typeR   t   strR   (   R    (    (    s7   lib/python2.7/site-packages/tornado/test/escape_test.pyt   test_escape_return_types   s    c         C` sL   |  j  t d  d  |  j  t d  d  |  j  t t d   d  d  S(   Ns   "foo"u   foou   "foo"u   "é"u   é(   R   R	   R   (   R    (    (    s7   lib/python2.7/site-packages/tornado/test/escape_test.pyt   test_json_decode   s    c         C` sd   |  j  t t d   d  t t k r` |  j  t t t d    d  |  j t t d  n  d  S(   Nu   és   (   R   R	   R
   t   bytesR7   R   t   assertRaisest   UnicodeDecodeError(   R    (    (    s7   lib/python2.7/site-packages/tornado/test/escape_test.pyt   test_json_encode   s    "c         C` s   |  j  t d  d  d  S(   Nu&   sequences     of    whitespace   charsu   sequences of whitespace chars(   R   R   (   R    (    (    s7   lib/python2.7/site-packages/tornado/test/escape_test.pyt   test_squeeze   s    c         C` s   i i d d 6d 6d d g d 6d	 d 6d d 6} |  j  t | d  i d d 6 |  j  t | d  d d g  |  j  t | d  d
  |  j  t | d  d  d  S(   Nt   barR5   t   dictt   listt   tupleR:   u   baru   foo(   R5   R?   (   u   foou   bar(   R   R   (   R    R&   (    (    s7   lib/python2.7/site-packages/tornado/test/escape_test.pyt   test_recursive_unicode   s    
! (   t   __name__t
   __module__R%   R)   R*   R-   R0   R4   R8   R9   R=   R>   RC   (    (    (    s7   lib/python2.7/site-packages/tornado/test/escape_test.pyR      s   												(   t
   __future__R    R   R   t   tornado.escapeR   R   R   R   R   R   R   R	   R
   R   R   t   tornado.utilR   t   tornado.test.utilR   t   TrueR   t   TestCaseR   (    (    (    s7   lib/python2.7/site-packages/tornado/test/escape_test.pyt   <module>   s   F


