(fix) rewrote the string sanitization to be 32-bit Unicode safe
parent
81f13404bf
commit
3c0059192d
1
NEWS
1
NEWS
|
@ -6,6 +6,7 @@ New features
|
||||||
|
|
||||||
Buf fixes
|
Buf fixes
|
||||||
- now always generate invitation updates when using EAS
|
- now always generate invitation updates when using EAS
|
||||||
|
- rewrote the string sanitization to be 32-bit Unicode safe
|
||||||
|
|
||||||
2.3.6 (2016-01-18)
|
2.3.6 (2016-01-18)
|
||||||
------------------
|
------------------
|
||||||
|
|
|
@ -291,34 +291,35 @@ static int cssEscapingCount;
|
||||||
//
|
//
|
||||||
- (NSString *) safeString
|
- (NSString *) safeString
|
||||||
{
|
{
|
||||||
|
NSData *data;
|
||||||
NSString *s;
|
NSString *s;
|
||||||
|
|
||||||
unichar *buf, *start, c;
|
const wchar_t *buf;
|
||||||
|
wchar_t *start, c;
|
||||||
int len, i, j;
|
int len, i, j;
|
||||||
|
|
||||||
len = [self length];
|
data = [self dataUsingEncoding: NSUTF32LittleEndianStringEncoding];
|
||||||
start = buf = (unichar *)malloc(len*sizeof(unichar));
|
len = [data length];
|
||||||
[self getCharacters: buf range: NSMakeRange(0, len)];
|
buf = [data bytes];
|
||||||
|
start = (wchar_t *)calloc(len, sizeof(wchar_t));
|
||||||
|
|
||||||
for (i = 0, j = 0; i < len; i++)
|
for (i = 0, j = 0; i < len/4; i++)
|
||||||
{
|
{
|
||||||
c = *buf;
|
c = buf[i];
|
||||||
|
|
||||||
if (c == 0x9 ||
|
if (c == 0x9 ||
|
||||||
c == 0xA ||
|
c == 0xA ||
|
||||||
c == 0xD ||
|
c == 0xD ||
|
||||||
(c >= 0x20 && c <= 0xD7FF) ||
|
(c >= 0x20 && c <= 0xD7FF) ||
|
||||||
(c >= 0xE000 && c <= 0xFFFD) ||
|
(c >= 0xE000 && c <= 0xFFFD) ||
|
||||||
(c >= (unichar)0x10000 && c <= (unichar)0x10FFFF))
|
(c >= (wchar_t)0x10000 && c <= (wchar_t)0x10FFFF))
|
||||||
{
|
{
|
||||||
*(start+j) = c;
|
start[j] = c;
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
s = [[NSString alloc] initWithCharactersNoCopy: start length: j freeWhenDone: YES];
|
s = [[NSString alloc] initWithBytesNoCopy: start length: j*sizeof(wchar_t) encoding: NSUTF32LittleEndianStringEncoding freeWhenDone: YES];
|
||||||
|
|
||||||
return AUTORELEASE(s);
|
return AUTORELEASE(s);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue