Partial fix/update for noncharacter codepoints,

also check for task exit more consistently


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@40125 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2016-10-05 17:44:00 +00:00
parent 63bd893d1e
commit 0fe344d12a
5 changed files with 13 additions and 29 deletions

View file

@ -1,3 +1,10 @@
2016-10-05 Richard Frith-Macdonald <rfm@gnu.org>
* Source/Additions/Unicode.m: Permit noncharacter unicode codepoints
* Source/GSString.m: Permit noncharacter unicode codepoints
* Source/NSNotificationQueue.m: Call GSPrivateCheckTasks()
* Source/NSRunLoop.m: Let GSPrivateNotifyASAP() check for task exit.
2016-09-19 Niels Grewe <niels.grewe@halbordnung.de>>
* Source/Additions/GSMime.m (charsetForXml):

View file

@ -746,11 +746,6 @@ GSUnicode(const unichar *chars, unsigned length,
while (i < length)
{
c = chars[i++];
if (c == 0xfffe || c == 0xffff
|| (c >= 0xfdd0 && c <= 0xfdef))
{
return i - 1; // Non-characters.
}
if (c >= 0xdc00 && c <= 0xdfff)
{
return i - 1; // Second half of a surrogate pair.
@ -973,16 +968,6 @@ GSToUnicode(unichar **dst, unsigned int *size, const unsigned char *src,
u = u & ~(0xffffffff << ((5 * sle) + 1));
spos += sle;
/*
* We discard invalid codepoints here.
*/
if (u > 0x10ffff || u == 0xfffe || u == 0xffff
|| (u >= 0xfdd0 && u <= 0xfdef))
{
result = NO; // Invalid character.
goto done;
}
if ((u >= 0xd800) && (u <= 0xdfff))
{
result = NO; // Unmatched half of surrogate pair.
@ -1664,10 +1649,7 @@ GSFromUnicode(unsigned char **dst, unsigned int *size, const unichar *src,
}
// 0xfeff is a zero-width-no-break-space inside text
if (u1 == 0xfffe // unexpected BOM
|| u1 == 0xffff // not a character
|| (u1 >= 0xfdd0 && u1 <= 0xfdef) // invalid character
|| (u1 >= 0xdc00 && u1 <= 0xdfff)) // bad pairing
if (u1 >= 0xdc00 && u1 <= 0xdfff) // bad pairing
{
if (strict)
{
@ -1786,10 +1768,7 @@ GSFromUnicode(unsigned char **dst, unsigned int *size, const unichar *src,
}
// 0xfeff is a zero-width-no-break-space inside text
if (u1 == 0xfffe // unexpected BOM
|| u1 == 0xffff // not a character
|| (u1 >= 0xfdd0 && u1 <= 0xfdef) // invalid character
|| (u1 >= 0xdc00 && u1 <= 0xdfff)) // bad pairing
if (u1 >= 0xdc00 && u1 <= 0xdfff) // bad pairing
{
if (strict)
{

View file

@ -136,8 +136,7 @@ lengthUTF8(const uint8_t *p, unsigned l, BOOL *ascii, BOOL *latin1)
/*
* We check for invalid codepoints here.
*/
if (u > 0x10ffff || u == 0xfffe || u == 0xffff
|| (u >= 0xfdd0 && u <= 0xfdef))
if (u > 0x10ffff)
{
[NSException raise: NSInternalInconsistencyException
format: @"Codepoint invalid in constant string"];
@ -261,8 +260,7 @@ nextUTF8(const uint8_t *p, unsigned l, unsigned *o, unichar *n)
/*
* We discard invalid codepoints here.
*/
if (u > 0x10ffff || u == 0xfffe || u == 0xffff
|| (u >= 0xfdd0 && u <= 0xfdef))
if (u > 0x10ffff)
{
[NSException raise: NSInvalidArgumentException
format: @"invalid unicode codepoint"];

View file

@ -643,6 +643,8 @@ GSPrivateNotifyASAP(NSString *mode)
{
NotificationQueueList *item;
GSPrivateCheckTasks();
for (item = currentList(); item; item = item->next)
{
if (item->queue)

View file

@ -1176,7 +1176,6 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now)
* a method to perform in this thread.
*/
[GSRunLoopCtxt awakenedBefore: nil];
GSPrivateCheckTasks();
[self _checkPerformers: context];
GSPrivateNotifyASAP(_currentMode);
[_contextStack removeObjectIdenticalTo: context];
@ -1271,7 +1270,6 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now)
/* Process any pending notifications.
*/
GSPrivateCheckTasks();
GSPrivateNotifyASAP(mode);
/* And process any performers scheduled in the loop (eg something from