Marcel Taeumel uploaded a new version of Network to project The Trunk: http://source.squeak.org/trunk/Network-mt.276.mcz
==================== Summary ====================
Name: Network-mt.276 Author: mt Time: 1 June 2023, 11:20:42.278467 am UUID: 31ecb208-cc84-5e46-bd7c-df7995d34ca9 Ancestors: Network-ct.275
Fixes MIMEType (parameter) parsing from MIME string.
MIMEType fromMIMEString: 'text/plain;charset=utf8' MIMEType fromMIMEString: 'Message/Partial; number=2; total=3; id="oc=jpbe0M2Yt4s@thumper.bellcore.com"'
=============== Diff against Network-ct.275 ===============
Item was changed: ----- Method: MIMEType class>>fromMIMEString: (in category 'instance creation') ----- fromMIMEString: mimeString + "Examples: + MIMEType fromMIMEString: 'text/plain' + MIMEType fromMIMEString: 'text/plain;charset=utf8' + MIMEType fromMIMEString: 'Message/Partial; number=2; total=3; id=""oc=jpbe0M2Yt4s@thumper.bellcore.com""'" + + | idx main sub parameters | - | idx main rest sub parameters | idx := mimeString indexOf: $/. idx = 0 ifTrue: [self error: 'Illegal mime type string "' , mimeString , '".']. main := mimeString copyFrom: 1 to: idx-1. + idx := mimeString indexOf: $; startingAt: idx+1. - rest := mimeString copyFrom: idx+1 to: mimeString size. - idx := mimeString indexOf: $;. idx = 0 + ifTrue: [ + sub := mimeString copyFrom: main size + 2 to: mimeString size] + ifFalse: [ | pos key val | + sub := mimeString copyFrom: main size + 2 to: idx-1. + parameters := OrderedDictionary new. + pos := idx. + [pos < mimeString size] whileTrue: [ + idx := idx + 1. "Skip $;" + [(mimeString at: idx) isSeparator] whileTrue: [idx := idx+1]. + pos := mimeString indexOf: $= startingAt: idx. + key := mimeString copyFrom: idx to: pos-1. + idx := pos+1. + (mimeString at: idx) = $" + ifFalse: ["token" + pos := mimeString indexOf: $; startingAt: idx. + pos = 0 ifTrue: [pos := mimeString size + 1]. + val := mimeString copyFrom: idx to: pos-1. + idx := pos] + ifTrue: ["quoted-string" + idx := idx+1. + pos := mimeString indexOf: $" startingAt: idx. + pos = 0 ifTrue: [self error: 'Illegal quoted-string in mime type string "' , mimeString , '".']. + val := mimeString copyFrom: idx to: pos-1. + idx := pos+1]. + parameters at: key put: val]]. - ifTrue: [sub := rest] - ifFalse: [ - sub := rest copyFrom: 1 to: idx. - parameters := rest copyFrom: idx+1 to: rest size]. ^self main: main sub: sub parameters: parameters !
Item was added: + ----- Method: MIMEType>>parameters (in category 'accessing') ----- + parameters + ^ parameters!
Item was changed: ----- Method: MIMEType>>printOn: (in category 'printing') ----- printOn: stream + stream + nextPutAll: main; nextPut: $/ ; + nextPutAll: sub. + parameters ifNotNil: [ + parameters isString + ifTrue: [ "OLD: broken parameter parsing" + stream nextPutAll: parameters] + ifFalse: [ "NEW: correct key-value parsing" + parameters keysAndValuesDo: [:key :value | + stream + nextPut: $; ; space; + nextPutAll: key; + nextPut: $= . + (value includesAnyOf: ';=/') + ifTrue: [stream nextPut: $"; nextPutAll: value; nextPut: $"] + ifFalse: [stream nextPutAll: value]] ]]! - nextPutAll: main; nextPut: $/ ; nextPutAll: sub!
squeak-dev@lists.squeakfoundation.org