mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 16:30:41 +00:00
Merge pull request #291 from qmfrederik/fixes/nsdata-base64-empty-string
`[NSData initWithBase64EncodedString]`: Fix decoding of an empty string
This commit is contained in:
commit
96a8613dbc
2 changed files with 13 additions and 0 deletions
|
@ -804,6 +804,13 @@ failure:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
length = dst - result;
|
length = dst - result;
|
||||||
|
|
||||||
|
if (length == 0)
|
||||||
|
{
|
||||||
|
NSZoneFree(zone, result);
|
||||||
|
return [self initWithBytesNoCopy: 0 length: 0 freeWhenDone: YES];
|
||||||
|
}
|
||||||
|
|
||||||
if (options & NSDataBase64DecodingIgnoreUnknownCharacters)
|
if (options & NSDataBase64DecodingIgnoreUnknownCharacters)
|
||||||
{
|
{
|
||||||
/* If the decoded length is a lot shorter than expected (because we
|
/* If the decoded length is a lot shorter than expected (because we
|
||||||
|
|
|
@ -127,6 +127,12 @@ int main()
|
||||||
PASS_EQUAL(data, ref, "base64 decoding Yml0bWFya2V0cyB1c2VyIGluZGVudGl0eQ==")
|
PASS_EQUAL(data, ref, "base64 decoding Yml0bWFya2V0cyB1c2VyIGluZGVudGl0eQ==")
|
||||||
[data release];
|
[data release];
|
||||||
|
|
||||||
|
data = [[NSData alloc] initWithBase64EncodedString: @"\n"
|
||||||
|
options: NSDataBase64DecodingIgnoreUnknownCharacters];
|
||||||
|
ref = [NSData dataWithBytes: "" length: 0];
|
||||||
|
PASS_EQUAL(data, ref, "base64 decoding empty string")
|
||||||
|
[data release];
|
||||||
|
|
||||||
[arp release]; arp = nil;
|
[arp release]; arp = nil;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue