[Pkg] The Trunk: Network-pre.223.mcz
commits at source.squeak.org
commits at source.squeak.org
Wed May 2 13:20:34 UTC 2018
Patrick Rein uploaded a new version of Network to project The Trunk:
http://source.squeak.org/trunk/Network-pre.223.mcz
==================== Summary ====================
Name: Network-pre.223
Author: pre
Time: 2 May 2018, 3:19:58.805873 pm
UUID: 6308303d-2839-b54d-9e44-90d16685e6be
Ancestors: Network-pre.222
Makes MIMEHeaderValue objects aware of qencoding by resolving the encoding issue at creation time.
=============== Diff against Network-pre.222 ===============
Item was changed:
----- Method: MIMEHeaderValue class>>forField:fromString: (in category 'instance creation') -----
forField: aFName fromString: aString
"Create a MIMEHeaderValue from aString. How it is parsed depends on whether it is a MIME specific field or a generic header field."
+ | decodedString |
+ decodedString := [aString decodeMimeHeader]
+ on: InvalidUTF8 , NoConverterFound do: [:e | aString].
(aFName beginsWith: 'content-')
+ ifTrue: [^self fromMIMEHeader: decodedString]
+ ifFalse: [^self fromTraditionalHeader: decodedString]
- ifTrue: [^self fromMIMEHeader: aString]
- ifFalse: [^self fromTraditionalHeader: aString]
!
Item was changed:
----- Method: MIMEHeaderValue class>>fromMIMEHeader: (in category 'instance creation') -----
fromMIMEHeader: aString
+ "This is the value of a MIME header field and so is parsed to extract the various parts.
+ This assumes a string without any special encodings (e.g. q encoding)."
- "This is the value of a MIME header field and so is parsed to extract the various parts"
| parts newValue parms |
newValue := self new.
parts := ReadStream on: (aString findTokens: ';').
newValue mainValue: parts next.
parms := Dictionary new.
parts do:
[:e | | separatorPos parmName parmValue |
separatorPos := e findAnySubStr: '=' startingAt: 1.
separatorPos <= e size
ifTrue:
[parmName := (e copyFrom: 1 to: separatorPos - 1) withBlanksTrimmed asLowercase.
parmValue := (e copyFrom: separatorPos + 1 to: e size) withBlanksTrimmed withoutQuoting.
parms at: parmName put: parmValue]].
newValue parameters: parms.
^ newValue
!
Item was changed:
----- Method: MIMEHeaderValue class>>fromTraditionalHeader: (in category 'instance creation') -----
fromTraditionalHeader: aString
+ "This is a traditional non-MIME header (like Subject:) and so should be stored whole.
+ This assumes a string without any special encodings (e.g. q encoding)."
- "This is a traditional non-MIME header (like Subject:) and so should be stored whole"
| newValue |
newValue := self new.
newValue mainValue: aString.
newValue parameters: #().
^newValue.
!
Item was changed:
----- Method: MIMEHeaderValue>>asHeaderValue (in category 'printing') -----
asHeaderValue
+ | strm result |
- | strm |
strm := WriteStream on: (String new: 20).
strm nextPutAll: mainValue.
parameters associationsDo: [:e |
strm
nextPut: $; ;
nextPutAll: e key;
nextPutAll: '=';
nextPutAll: e value].
+ ^ ((result := strm contents) anySatisfy: [:c | c isAscii not])
+ ifTrue: [QEncodingMimeConverter mimeEncode: result]
+ ifFalse: [result]
+ !
- ^ QEncodingMimeConverter mimeEncode: strm contents!
Item was changed:
----- Method: MIMEHeaderValue>>mainValue (in category 'accessing') -----
mainValue
+ ^ mainValue!
- ^ [mainValue decodeMimeHeader]
- on: InvalidUTF8 , NoConverterFound do: [:e | mainValue]!
More information about the Packages
mailing list