2
0
mirror of https://opendev.org/x/pyghmi synced 2026-01-10 02:02:30 +00:00

Change multipart boundary

While base64 should generate a valid boundary, some implementations balk at /.

Change to urlsafe alphabet.

Also, technically our boundary was potentially too big depending on readings of standards, reduce so that under any reading we are less than 70 characteres even including added '--' characters.

Change-Id: Id887a03eeb63a8d2bef000ae5e7365d269349906
This commit is contained in:
Jarrod Johnson
2025-12-09 15:18:34 -05:00
parent fe7a1dbfe7
commit dc929c9e51

View File

@@ -99,7 +99,7 @@ class FileDownloader(threading.Thread):
def get_upload_form(filename, data, formname, otherfields, boundary=BND):
if not boundary:
boundary = base64.b64encode(os.urandom(54))[:70]
boundary = base64.urlsafe_b64encode(os.urandom(54))[:66]
ffilename = filename.split('/')[-1]
if not formname:
formname = ffilename