@@ -863,7 +863,7 @@ def test_bad_gzip_request(self):
863863 p .pow (6 , 8 )
864864 p ("close" )()
865865
866- def test_gsip_response (self ):
866+ def test_gzip_response (self ):
867867 t = self .Transport ()
868868 p = xmlrpclib .ServerProxy (URL , transport = t )
869869 old = self .requestHandler .encode_threshold
@@ -877,6 +877,27 @@ def test_gsip_response(self):
877877 self .requestHandler .encode_threshold = old
878878 self .assertTrue (a > b )
879879
880+
881+ @unittest .skipIf (gzip is None , 'requires gzip' )
882+ class GzipUtilTestCase (unittest .TestCase ):
883+
884+ def test_gzip_decode_limit (self ):
885+ max_gzip_decode = 20 * 1024 * 1024
886+ data = b'\0 ' * max_gzip_decode
887+ encoded = xmlrpclib .gzip_encode (data )
888+ decoded = xmlrpclib .gzip_decode (encoded )
889+ self .assertEqual (len (decoded ), max_gzip_decode )
890+
891+ data = b'\0 ' * (max_gzip_decode + 1 )
892+ encoded = xmlrpclib .gzip_encode (data )
893+
894+ with self .assertRaisesRegexp (ValueError ,
895+ "max gzipped payload length exceeded" ):
896+ xmlrpclib .gzip_decode (encoded )
897+
898+ xmlrpclib .gzip_decode (encoded , max_decode = - 1 )
899+
900+
880901#Test special attributes of the ServerProxy object
881902class ServerProxyTestCase (unittest .TestCase ):
882903 def setUp (self ):
@@ -1105,7 +1126,7 @@ def test_main():
11051126 support .run_unittest (XMLRPCTestCase , HelperTestCase , DateTimeTestCase ,
11061127 BinaryTestCase , FaultTestCase , UseBuiltinTypesTestCase ,
11071128 SimpleServerTestCase , KeepaliveServerTestCase1 ,
1108- KeepaliveServerTestCase2 , GzipServerTestCase ,
1129+ KeepaliveServerTestCase2 , GzipServerTestCase , GzipUtilTestCase ,
11091130 MultiPathServerTestCase , ServerProxyTestCase , FailingServerTestCase ,
11101131 CGIHandlerTestCase )
11111132
0 commit comments