ó
ìUzMc           @   sA   d  d l  Z  d  d l Z d  d l Z d e  j f d „  ƒ  YZ d S(   iÿÿÿÿNt   TestEncodeForHTMLc           B   s,   e  Z d  „  Z d „  Z d „  Z d „  Z RS(   c         C   s(   t  j j ƒ  |  _ t  j j ƒ  |  _ d  S(   N(   t
   simplejsont   decodert   JSONDecodert   encodert   JSONEncoderForHTML(   t   self(    (    sI   /usr/lib/python2.7/dist-packages/simplejson/tests/test_encode_for_html.pyt   setUp	   s    c         C   sX   |  j  d |  j j d ƒ ƒ |  j  d |  j j d ƒ ƒ |  j  d |  j j d ƒ ƒ d  S(   Ns   "\u0026"t   &s   "\u003c"t   <s   "\u003e"t   >(   t   assertEqualR   t   encode(   R   (    (    sI   /usr/lib/python2.7/dist-packages/simplejson/tests/test_encode_for_html.pyt   test_basic_encode   s    c         C   s=   x6 d D]. } |  j  | |  j j |  j j | ƒ ƒ ƒ q Wd  S(   Ns   &<>(   R   R   t   decodeR   R   (   R   t   char(    (    sI   /usr/lib/python2.7/dist-packages/simplejson/tests/test_encode_for_html.pyt   test_basic_roundtrip   s    c         C   sN   d } |  j  d |  j j | ƒ ƒ |  j  | |  j j |  j j | ƒ ƒ ƒ d  S(   Ns)   </script><script>alert("gotcha")</script>sK   "\u003c/script\u003e\u003cscript\u003ealert(\"gotcha\")\u003c/script\u003e"(   R   R   R   R   R   (   R   t
   bad_string(    (    sI   /usr/lib/python2.7/dist-packages/simplejson/tests/test_encode_for_html.pyt   test_prevent_script_breakout   s    (   t   __name__t
   __module__R   R   R   R   (    (    (    sI   /usr/lib/python2.7/dist-packages/simplejson/tests/test_encode_for_html.pyR       s   			(   t   unittestt   simplejson.decoderR   t   simplejson.encodert   TestCaseR    (    (    (    sI   /usr/lib/python2.7/dist-packages/simplejson/tests/test_encode_for_html.pyt   <module>   s   