[squeak-dev] The Trunk: WebClient-Core-topa.112.mcz

Tobias Pape Das.Linux at gmx.de
Wed Sep 20 17:09:44 UTC 2017


> On 20.09.2017, at 17:56, Levente Uzonyi <leves at caesar.elte.hu> wrote:
> 
> On Wed, 20 Sep 2017, commits at source.squeak.org wrote:
> 
>> Tobias Pape uploaded a new version of WebClient-Core to project The Trunk:
>> http://source.squeak.org/trunk/WebClient-Core-topa.112.mcz
>> 
>> ==================== Summary ====================
>> 
>> Name: WebClient-Core-topa.112
>> Author: topa
>> Time: 20 September 2017, 5:29:06.096983 pm
>> UUID: 60b494fc-0652-4a28-be5a-1578963e5aed
>> Ancestors: WebClient-Core-topa.111
>> 
>> Abide Postel's law for text conversion.
>> 
>> Be conservative in what you do, be liberal in what you accept from others.
>> 
>> =============== Diff against WebClient-Core-topa.111 ===============
>> 
>> Item was changed:
>> ----- Method: WebMessage>>getContentWithProgress: (in category 'private') -----
>> getContentWithProgress: progressBlockOrNil
>> 	"Reads available content and returns it."
>> 
>> 	| length result |
>> 	length := self contentLength.
>> 	result := (stream isBinary ifTrue:[ ByteArray ] ifFalse: [ ByteString ])
>> 		new: (length ifNil: [ 1000 ])
>> 		streamContents: [ :outputStream |
>> 			self
>> 				streamFrom: stream
>> 				to: outputStream
>> 				size: length
>> 				progress: progressBlockOrNil ].
>> 	self decoderForContentEncoding ifNotNil: [:decoder |
>> 		result := (decoder on: result) upToEnd].
>> 	self textConverterForContentType ifNotNil: [:converter |
>> + 		[result := result convertFromWithConverter: converter]
>> + 		on: InvalidUTF8 "some servers lie"
>> + 		do: [^ result]].
>> - 		result := result convertFromWithConverter: converter].
> 
> Why ignore only InvalidUTF8?

Because there's no InvalidTextConversation yet ;)
What would be appropriate? Error?

Best regards
	-Tobias

> 
> Levente
> 
>> 	^ result
>> !
>> 
>> Item was changed:
>> ----- Method: WebMessage>>textConverterForContentType (in category 'accessing') -----
>> textConverterForContentType
>> 
>> 	| index contentType |
>> 	contentType := self contentType.
>> 	contentType size < 8 ifTrue: [ ^nil ].
>> - 	(contentType beginsWithAnyOf: #('application/' 'image/' 'video/' 'audio/')) ifTrue: [^nil].
>> 	index := contentType findString: 'charset=' startingAt: 1 caseSensitive: false.
>> 	index = 0 ifTrue: [ ^nil ].
>> 	^TextConverter newForEncoding: (contentType allButFirst: index + 7) "'charset=' size - 1"!



More information about the Squeak-dev mailing list