Ejemplo n.º 1
0
 def test_escape_html(self):
     assert_equal(sanitize.clean_tag("<script> evil code </script>"), "&lt;script&gt; evil code &lt;/script&gt;")
     assert_equal(
         sanitize.clean_tag("<img src=javascript:moreevil><img>"),
         "&lt;img src=&quot;javascript:moreevil&quot;&gt;&lt;img&gt;",
     )
     assert_equal(sanitize.clean_tag("<iframe src=evilsite>"), "&lt;iframe src=&quot;evilsite&quot;&gt;")
     assert_equal(
         sanitize.clean_tag(");</span><script></script><span>"),
         ");&lt;/span&gt;&lt;script&gt;&lt;/script&gt;&lt;span&gt;",
     )
Ejemplo n.º 2
0
def project_removetag(auth, node, **kwargs):

    tag = clean_tag(kwargs['tag'])

    if tag:
        node.remove_tag(tag=tag, auth=auth)
        return {'status': 'success'}
Ejemplo n.º 3
0
def project_removetag(auth, node, **kwargs):

    tag = clean_tag(kwargs['tag'])

    if tag:
        node.remove_tag(tag=tag, auth=auth)
        return {'status': 'success'}
Ejemplo n.º 4
0
 def test_escape_html(self):
     assert_equal(
         sanitize.clean_tag('<script> evil code </script>'),
         '&lt;script&gt; evil code &lt;/script&gt;',
     )
     assert_equal(
         sanitize.clean_tag('<img src=javascript:moreevil><img>'),
         '&lt;img src=&quot;javascript:moreevil&quot;&gt;&lt;img&gt;',
     )
     assert_equal(
         sanitize.clean_tag('<iframe src=evilsite>'),
         '&lt;iframe src=&quot;evilsite&quot;&gt;',
     )
     assert_equal(
         sanitize.clean_tag(');</span><script></script><span>'),
         ');&lt;/span&gt;&lt;script&gt;&lt;/script&gt;&lt;span&gt;',
     )
Ejemplo n.º 5
0
def project_removetag(auth, **kwargs):

    tag = clean_tag(kwargs['tag'])
    node = kwargs['node'] or kwargs['project']

    if tag:
        node.remove_tag(tag=tag, auth=auth)
        return {'status': 'success'}
Ejemplo n.º 6
0
def project_removetag(auth, **kwargs):

    tag = clean_tag(kwargs['tag'])
    node = kwargs['node'] or kwargs['project']

    if tag:
        node.remove_tag(tag=tag, auth=auth)
        return {'status': 'success'}
Ejemplo n.º 7
0
def project_addtag(auth, node, **kwargs):

    tag = clean_tag(kwargs['tag'])
    if tag:
        try:
            node.add_tag(tag=tag, auth=auth)
            return {'status': 'success'}, http.CREATED
        except ValidationError:
            return {'status': 'error'}, http.BAD_REQUEST
Ejemplo n.º 8
0
def project_addtag(auth, node, **kwargs):

    tag = clean_tag(kwargs['tag'])
    if tag:
        try:
            node.add_tag(tag=tag, auth=auth)
            return {'status': 'success'}, http.CREATED
        except ValidationError:
            return {'status': 'error'}, http.BAD_REQUEST
Ejemplo n.º 9
0
 def test_clean_tag(self):
     assert_equal(
         sanitize.clean_tag('\'\'\'\'\'"""""""<script></script>'),
         '&#39&#39&#39&#39&#39&quot;&quot;&quot;&quot;&quot;&quot;&quot;&lt;script&gt;&lt;/script&gt;',
     )
Ejemplo n.º 10
0
 def test_clean_tag(self):
     assert_equal(
         sanitize.clean_tag('\'\'\'\'\'"""""""<script></script>'),
         '&#39&#39&#39&#39&#39&quot;&quot;&quot;&quot;&quot;&quot;&quot;&lt;script&gt;&lt;/script&gt;',
     )