mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-01 09:02:01 +00:00
Minor checks added
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@13925 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
e3e8e81196
commit
86c8f508ae
2 changed files with 65 additions and 20 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2002-06-21 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/GSMime.m: add a few consistency checks to raise an exception
|
||||||
|
if we try to unparse a GSMimeDocument with inconsistent headers and
|
||||||
|
content.
|
||||||
|
|
||||||
2002-06-19 Adam Fedor <fedor@gnu.org>
|
2002-06-19 Adam Fedor <fedor@gnu.org>
|
||||||
|
|
||||||
* Source/GSLocale.m (GSSetLocaleC): Only set locale for LC_CTYPE.
|
* Source/GSLocale.m (GSSetLocaleC): Only set locale for LC_CTYPE.
|
||||||
|
|
|
@ -2588,25 +2588,33 @@ static NSCharacterSet *tokenSet = nil;
|
||||||
BOOL conv = YES;
|
BOOL conv = YES;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Capitalise the header name.
|
* Capitalise the header name. However, the version header is a special
|
||||||
|
* case - it is defined as being literally 'MIME-Version'
|
||||||
*/
|
*/
|
||||||
memcpy(buf, [d bytes], l);
|
memcpy(buf, [d bytes], l);
|
||||||
while (i < l)
|
if (l == 12 && memcmp(buf, "MIME-Version", 12) == 0)
|
||||||
{
|
{
|
||||||
if (conv == YES)
|
memcpy(buf, "MIME-Version", 12);
|
||||||
{
|
}
|
||||||
if (islower(buf[i]))
|
else
|
||||||
|
{
|
||||||
|
while (i < l)
|
||||||
|
{
|
||||||
|
if (conv == YES)
|
||||||
{
|
{
|
||||||
buf[i] = toupper(buf[i]);
|
if (islower(buf[i]))
|
||||||
|
{
|
||||||
|
buf[i] = toupper(buf[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (buf[i++] == '-')
|
||||||
|
{
|
||||||
|
conv = YES;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
conv = NO;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (buf[i++] == '-')
|
|
||||||
{
|
|
||||||
conv = YES;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
conv = NO;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[md appendBytes: buf length: l];
|
[md appendBytes: buf length: l];
|
||||||
|
@ -3532,6 +3540,7 @@ static NSCharacterSet *tokenSet = nil;
|
||||||
GSMimeHeader *enc;
|
GSMimeHeader *enc;
|
||||||
GSMimeHeader *hdr;
|
GSMimeHeader *hdr;
|
||||||
NSData *boundary;
|
NSData *boundary;
|
||||||
|
BOOL is7bit = YES;
|
||||||
|
|
||||||
if (isOuter == YES)
|
if (isOuter == YES)
|
||||||
{
|
{
|
||||||
|
@ -3592,11 +3601,26 @@ static NSCharacterSet *tokenSet = nil;
|
||||||
NSString *v;
|
NSString *v;
|
||||||
|
|
||||||
enc = [self headerNamed: @"content-transfer-encoding"];
|
enc = [self headerNamed: @"content-transfer-encoding"];
|
||||||
if (enc != nil)
|
if (enc == nil)
|
||||||
|
{
|
||||||
|
enc = [GSMimeHeader alloc];
|
||||||
|
enc = [enc initWithName: @"content-transfer-encoding"
|
||||||
|
value: @"7bit"
|
||||||
|
parameters: nil];
|
||||||
|
[self addHeader: enc];
|
||||||
|
RELEASE(enc);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
[NSException raise: NSInternalInconsistencyException
|
v = [enc value];
|
||||||
format: @"[%@ -%@:] content transfer encoding not supported",
|
if ((is7bit = [v isEqual: @"7bit"]) == NO
|
||||||
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
|
&& [v isEqual: @"8bit"] == NO && [v isEqual: @"binary"] == NO)
|
||||||
|
{
|
||||||
|
[NSException raise: NSInternalInconsistencyException
|
||||||
|
format: @"[%@ -%@:] %@ illegal for multipart",
|
||||||
|
NSStringFromClass([self class]), NSStringFromSelector(_cmd),
|
||||||
|
v];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
v = [type parameterForKey: @"boundary"];
|
v = [type parameterForKey: @"boundary"];
|
||||||
if (v == nil)
|
if (v == nil)
|
||||||
|
@ -3675,9 +3699,24 @@ static NSCharacterSet *tokenSet = nil;
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
CREATE_AUTORELEASE_POOL(arp);
|
CREATE_AUTORELEASE_POOL(arp);
|
||||||
NSMutableData *part = [[content objectAtIndex: i] rawMimeData: NO];
|
GSMimeDocument *part = [content objectAtIndex: i];
|
||||||
|
NSMutableData *rawPart = [part rawMimeData: NO];
|
||||||
|
|
||||||
[md appendData: part];
|
if (is7bit == YES)
|
||||||
|
{
|
||||||
|
NSString *v;
|
||||||
|
|
||||||
|
enc = [part headerNamed: @"content-transport-encoding"];
|
||||||
|
v = [enc value];
|
||||||
|
if (v != nil && ([v isEqual: @"8bit"] || [v isEqual: @"binary"]))
|
||||||
|
{
|
||||||
|
[NSException raise: NSInternalInconsistencyException
|
||||||
|
format: @"[%@ -%@:] bad part encoding for 7bit container",
|
||||||
|
NSStringFromClass([self class]),
|
||||||
|
NSStringFromSelector(_cmd)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[md appendData: rawPart];
|
||||||
[md appendBytes: "\r\n--" length: 4];
|
[md appendBytes: "\r\n--" length: 4];
|
||||||
[md appendData: boundary];
|
[md appendData: boundary];
|
||||||
[md appendBytes: "\r\n" length: 2];
|
[md appendBytes: "\r\n" length: 2];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue