Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3a54c3e

Browse files
committed
Merge: #10510: make distuitls upload/register use HTML standards compliant CRLF.
2 parents f7fee33 + 9ce6967 commit 3a54c3e

4 files changed

Lines changed: 10 additions & 6 deletions

File tree

Lib/distutils/command/upload.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,11 @@ def upload_file(self, command, pyversion, filename):
141141

142142
# Build up the MIME payload for the POST data
143143
boundary = '--------------GHSKFJDLGDS7543FJKLFHRE75642756743254'
144-
sep_boundary = b'\n--' + boundary.encode('ascii')
145-
end_boundary = sep_boundary + b'--'
144+
sep_boundary = b'\r\n--' + boundary.encode('ascii')
145+
end_boundary = sep_boundary + b'--\r\n'
146146
body = io.BytesIO()
147147
for key, value in data.items():
148-
title = '\nContent-Disposition: form-data; name="%s"' % key
148+
title = '\r\nContent-Disposition: form-data; name="%s"' % key
149149
# handle multiple entries for the same name
150150
if not isinstance(value, list):
151151
value = [value]
@@ -157,12 +157,12 @@ def upload_file(self, command, pyversion, filename):
157157
value = str(value).encode('utf-8')
158158
body.write(sep_boundary)
159159
body.write(title.encode('utf-8'))
160-
body.write(b"\n\n")
160+
body.write(b"\r\n\r\n")
161161
body.write(value)
162162
if value and value[-1:] == b'\r':
163163
body.write(b'\n') # write an extra newline (lurve Macs)
164164
body.write(end_boundary)
165-
body.write(b"\n")
165+
body.write(b"\r\n")
166166
body = body.getvalue()
167167

168168
msg = "Submitting %s to %s" % (filename, self.repository)

Lib/distutils/tests/test_upload.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def test_upload(self):
127127

128128
# what did we send ?
129129
headers = dict(self.last_open.req.headers)
130-
self.assertEqual(headers['Content-length'], '2087')
130+
self.assertEqual(headers['Content-length'], '2163')
131131
content_type = headers['Content-type']
132132
self.assertTrue(content_type.startswith('multipart/form-data'))
133133
self.assertEqual(self.last_open.req.get_method(), 'POST')

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ Jason R. Coombs
281281
Garrett Cooper
282282
Greg Copeland
283283
Aldo Cortesi
284+
Ian Cordasco
284285
David Costanzo
285286
Scott Cotton
286287
Greg Couch

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ Core and Builtins
145145
Library
146146
-------
147147

148+
- Issue #10510: distutils register and upload methods now use HTML standards
149+
compliant CRLF line endings.
150+
148151
- Issue #9850: Fixed macpath.join() for empty first component. Patch by
149152
Oleg Oshmyan.
150153

0 commit comments

Comments
 (0)