Beispiel #1
0
 def test_filterObject(self):
     ILLEGAL_DATA = {u"foo": u"\x00data\x00test\uffff\ufffe\ud800\udc79"}
     LEGAL_DATA = {u"foo": u"?data?test\U00010000"}
     EXPECTED_DATA = {
         u"foo": u"\ufffddata\ufffdtest\ufffd\ufffd\ufffd\ufffd"}
     self.assertEqual(EXPECTED_DATA, guestIF._filterObject(ILLEGAL_DATA))
     self.assertEqual(LEGAL_DATA, guestIF._filterObject(LEGAL_DATA))
Beispiel #2
0
 def test_filterObject(self):
     ILLEGAL_DATA = {u"foo": u"\x00data\x00test\uffff\ufffe\ud800\udc79"}
     LEGAL_DATA = {u"foo": u"?data?test\U00010000"}
     EXPECTED_DATA = {
         u"foo": u"\ufffddata\ufffdtest\ufffd\ufffd\ufffd\ufffd"
     }
     self.assertEqual(EXPECTED_DATA, guestIF._filterObject(ILLEGAL_DATA))
     self.assertEqual(LEGAL_DATA, guestIF._filterObject(LEGAL_DATA))
Beispiel #3
0
    def test_StringAndObjectFiltering(self):
        ILLEGAL_DATA = json.dumps({"foo": "\x00data\x00test"})
        LEGAL_DATA = json.dumps({"foo": "?data?test"})
        EXPECTED_DATA = {"foo": "?data?test"}

        filtered = guestIF._filterXmlChars(ILLEGAL_DATA)
        parsed = json.loads(filtered.decode('utf-8'))
        filt_obj = guestIF._filterObject(parsed)
        self.assertEqual(filt_obj, EXPECTED_DATA)

        filtered = guestIF._filterXmlChars(LEGAL_DATA)
        parsed = json.loads(filtered.decode('utf-8'))
        filt_obj = guestIF._filterObject(parsed)
        self.assertEqual(filt_obj, EXPECTED_DATA)
Beispiel #4
0
 def test_filterObject(self):
     ILLEGAL_DATA = {"foo": "\x00data\x00test"}
     LEGAL_DATA = {"foo": "?data?test"}
     EXPECTED_DATA = {"foo": "?data?test"}
     self.assertEqual(EXPECTED_DATA, guestIF._filterObject(ILLEGAL_DATA))
     self.assertEqual(EXPECTED_DATA, guestIF._filterObject(LEGAL_DATA))