Commits

Amaury Forgeot d'Arc committed 76915c4

Allow unterminated utf7 sequences when final=False

Comments (0)

Files changed (2)

pypy/rlib/runicode.py

             result.append(unichr(oc))
             pos += 1
 
-    if inShift:
+    if inShift and final:
         endinpos = size
         msg = "unterminated shift sequence"
         res, pos = errorhandler(errors, 'utf-7', msg, s, startinpos, pos)

pypy/rlib/test/test_runicode.py

         py.test.raises(UnicodeDecodeError, runicode.str_decode_utf_16_le,
                        s, len(s), True)
 
+    def test_utf7_partial(self):
+        s = u"a+-b".encode('utf-7')
+        assert s == "a+--b"
+        decode = self.getdecoder('utf-7')
+        assert decode(s, 1, None)[0] == u'a'
+        assert decode(s, 2, None)[0] == u'a'
+        assert decode(s, 3, None)[0] == u'a+'
+        assert decode(s, 4, None)[0] == u'a+-'
+        assert decode(s, 5, None)[0] == u'a+-b'
+
 
 class TestEncoding(UnicodeTests):
     def test_all_ascii(self):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.