]> granicus.if.org Git - python/commitdiff
#10510: make distuitls upload/register use HTML standards compliant CRLF.
authorR David Murray <rdmurray@bitdance.com>
Sat, 27 Sep 2014 20:59:04 +0000 (16:59 -0400)
committerR David Murray <rdmurray@bitdance.com>
Sat, 27 Sep 2014 20:59:04 +0000 (16:59 -0400)
Patch by Ian Cordasco, approved by Éric Araujo.

Lib/distutils/command/upload.py
Lib/distutils/tests/test_upload.py
Misc/ACKS
Misc/NEWS

index 9aa54eee5ebf740cafd91fbd8f9d2edc8e1fd728..b773f47f76845252a9343c2cfc37a6d70d404b2e 100644 (file)
@@ -136,8 +136,8 @@ class upload(PyPIRCCommand):
 
         # Build up the MIME payload for the POST data
         boundary = '--------------GHSKFJDLGDS7543FJKLFHRE75642756743254'
-        sep_boundary = '\n--' + boundary
-        end_boundary = sep_boundary + '--'
+        sep_boundary = '\r\n--' + boundary
+        end_boundary = sep_boundary + '--\r\n'
         body = StringIO.StringIO()
         for key, value in data.items():
             # handle multiple entries for the same name
@@ -151,14 +151,13 @@ class upload(PyPIRCCommand):
                     fn = ""
 
                 body.write(sep_boundary)
-                body.write('\nContent-Disposition: form-data; name="%s"'%key)
+                body.write('\r\nContent-Disposition: form-data; name="%s"' % key)
                 body.write(fn)
-                body.write("\n\n")
+                body.write("\r\n\r\n")
                 body.write(value)
                 if value and value[-1] == '\r':
                     body.write('\n')  # write an extra newline (lurve Macs)
         body.write(end_boundary)
-        body.write("\n")
         body = body.getvalue()
 
         self.announce("Submitting %s to %s" % (filename, self.repository), log.INFO)
index 17735d3974450e5020c6568033c1a2ad3841e9f9..9290f9cda59b7a46c2d0e8cf701726ccd60952ac 100644 (file)
@@ -119,7 +119,7 @@ class uploadTestCase(PyPIRCCommandTestCase):
         # what did we send ?
         self.assertIn('dédé', self.last_open.req.data)
         headers = dict(self.last_open.req.headers)
-        self.assertEqual(headers['Content-length'], '2085')
+        self.assertEqual(headers['Content-length'], '2159')
         self.assertTrue(headers['Content-type'].startswith('multipart/form-data'))
         self.assertEqual(self.last_open.req.get_method(), 'POST')
         self.assertEqual(self.last_open.req.get_full_url(),
index c86acd949285c8389d25bb854b961b3a327d3ca8..3fb951cddc90ec65a1086bd5acc9243544cae53c 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -274,6 +274,7 @@ David M. Cooke
 Jason R. Coombs
 Garrett Cooper
 Greg Copeland
+Ian Cordasco
 Aldo Cortesi
 David Costanzo
 Scott Cotton
index b50f45d21497a3dc3dc6b0c9b74f1d0bd6289abe..da2c5544db442d492a17a9e19e2ec78f9d5651dc 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -22,6 +22,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #10510: distutils register and upload methods now use HTML standards
+  compliant CRLF line endings.
+
 - Issue #9850: Fixed macpath.join() for empty first component.  Patch by
   Oleg Oshmyan.