Skip to content

Commit

Permalink
MultipartInjector now also supports replacing file size in the URL
Browse files Browse the repository at this point in the history
  • Loading branch information
floyd committed Apr 2, 2019
1 parent 30b10e1 commit ba14014
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion UploadScanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -5025,13 +5025,20 @@ def get_request(self, filename, content, content_type=None):
# print "Replacing old filename", old_filename, "with new", new_filename, "in multipart number", index
new_multipart = multipart.replace(old_filename, new_filename)
multiparts[index] = new_multipart
# Now also take care that a filename in the URL is replaced with the new filename
# A filename in the URL is replaced with the new filename
if self.opts.replace_filename and old_filename and old_filename != new_filename:
status_line = status_headers.split(self._newline)[0]
headers = self._newline.join(status_headers.split(self._newline)[1:])
status_line = status_line.replace(old_filename, urllib.quote(new_filename))
status_line = status_line.replace(urllib.quote(old_filename), urllib.quote(new_filename))
status_headers = status_line + self._newline + headers
# The file size in the URL is replaced with the new filename
if self.opts.replace_filesize and old_size > 100 and old_size and old_size != new_size:
status_line = status_headers.split(self._newline)[0]
if old_size in status_line:
headers = self._newline.join(status_headers.split(self._newline)[1:])
status_line = status_line.replace(old_size, new_size)
status_headers = status_line + self._newline + headers
# Now finally set the file content
new = self._set_multipart_content(multiparts[meant_multipart_index], content, content_type)
if new:
Expand Down

0 comments on commit ba14014

Please sign in to comment.