示例#1
0
    def test_payload_is_all_content_no_break(self):
        css_code = 'PAYLOAD'
        contexts = get_css_context(css_code, css_code)

        self.assertEqual(len(contexts), 1, contexts)
        context = contexts[0]

        self.assertIsInstance(context, GenericStyleContext)
        self.assertFalse(context.can_break())
示例#2
0
    def test_payload_value_double_quote_break(self):
        payload = 'PAYLOAD:("'
        css_code = 'font-family: Georgia, "Times New Roman %s";' % payload
        contexts = get_css_context(css_code, payload)

        self.assertEqual(len(contexts), 1, contexts)
        context = contexts[0]

        self.assertIsInstance(context, StyleDoubleQuoteString)
        self.assertTrue(context.can_break())
示例#3
0
    def test_payload_in_value(self):
        payload = 'PAYLOAD:('
        css_code = 'body {background-color:%s}' % payload
        contexts = get_css_context(css_code, payload)

        self.assertEqual(len(contexts), 1, contexts)
        context = contexts[0]

        self.assertIsInstance(context, GenericStyleContext)
        self.assertTrue(context.can_break())
示例#4
0
    def test_payload_in_property(self):
        payload = 'PAYLOAD:('
        css_code = 'body {%s:lightgray}' % payload
        contexts = get_css_context(css_code, payload)

        self.assertEqual(len(contexts), 1, contexts)
        context = contexts[0]

        self.assertIsInstance(context, GenericStyleContext)
        self.assertTrue(context.can_break())
示例#5
0
    def test_payload_value_single_quote(self):
        payload = "PAYLOAD:('"
        css_code = "background: url('%s')" % payload
        contexts = get_css_context(css_code, payload)

        self.assertEqual(len(contexts), 1, contexts)
        context = contexts[0]

        self.assertIsInstance(context, StyleSingleQuoteString)
        self.assertTrue(context.can_break())
示例#6
0
    def test_comment_false_positive(self):
        payload = 'PAYLOAD'
        css_code = '''
        p {
            color: red;
            background: url('/* This is a false positive test %s */');
            text-align: center;
        }
        '''
        contexts = get_css_context(css_code % payload, payload)

        self.assertEqual(len(contexts), 1, contexts)
        context = contexts[0]

        self.assertIsInstance(context, StyleSingleQuoteString)
        self.assertFalse(context.can_break())
示例#7
0
    def test_payload_in_comment_break(self):
        payload = 'PAYLOAD*/:('
        css_code = '''
        p {
            color: red;
            /* This is a single-line %s comment */
            text-align: center;
        }
        '''
        contexts = get_css_context(css_code % payload, payload)

        self.assertEqual(len(contexts), 1, contexts)
        context = contexts[0]

        self.assertIsInstance(context, StyleComment)
        self.assertTrue(context.can_break())