[squeak-dev] The Inbox: WebClient-Core-ct.124.mcz

commits at source.squeak.org commits at source.squeak.org
Sun Aug 30 23:54:13 UTC 2020


Christoph Thiede uploaded a new version of WebClient-Core to project The Inbox:
http://source.squeak.org/inbox/WebClient-Core-ct.124.mcz

==================== Summary ====================

Name: WebClient-Core-ct.124
Author: ct
Time: 31 August 2020, 1:54:11.685896 am
UUID: b0d7790c-c195-6e4d-ad0f-fce8cf8b3b00
Ancestors: WebClient-Core-ul.123

Fixes a syntax error in multipart/form-data encoding

Phew! It costed me a few hours to track some higher-level application bug down to this low level code ...

=============== Diff against WebClient-Core-ul.123 ===============

Item was changed:
  ----- Method: WebUtils class>>encodeMultipartForm:boundary: (in category 'decoding') -----
  encodeMultipartForm: fieldMap boundary: boundary
  	"Encodes the fieldMap as multipart/form-data.
  
  	The fieldMap may contain MIMEDocument instances to indicate the presence
  	of a file to upload to the server. If the MIMEDocument is present, its
  	content type and file name will be used for the upload.
  
  	The fieldMap can be EITHER an array of associations OR a Dictionary of 
  	key value pairs (the former is useful for providing multiple fields and/or 
  	specifying the order of fields)."
  
  	^String streamContents:[:stream|
  		(fieldMap as: Dictionary) keysAndValuesDo:[:fieldName :fieldValue | | fieldContent |
  			"Write multipart boundary and common headers"
  			stream nextPutAll: '--', boundary; crlf.
  			stream nextPutAll: 'Content-Disposition: form-data; name="', fieldName, '"'.
  			"Figure out if this is a file upload"
  			(fieldValue isKindOf: MIMEDocument) ifTrue:[
+ 				stream nextPutAll: '; filename="', fieldValue url pathForFile, '"'; crlf.
- 				stream nextPutAll: ' filename="', fieldValue url pathForFile, '"'; crlf.
  				stream nextPutAll: 'Content-Type: ', fieldValue contentType.
  				fieldContent := (fieldValue content ifNil:[
  					(FileStream readOnlyFileNamed: fieldValue url pathForFile) contentsOfEntireFile.
  				]) asString.
  			] ifFalse: [fieldContent := fieldValue].
  			stream crlf; crlf.
  			stream nextPutAll: fieldContent asString.
  			stream crlf.
  		].
  		stream nextPutAll: '--', boundary, '--', String crlf.
  	].
  !



More information about the Squeak-dev mailing list