Index: src/OFString+XMLUnescaping.m ================================================================== --- src/OFString+XMLUnescaping.m +++ src/OFString+XMLUnescaping.m @@ -92,48 +92,41 @@ string = [self cString]; length = [self cStringLength]; ret = [OFMutableString string]; - /* - * This is safe as we already called -[cString] on self and thus can be - * sure the string is correctly initialized, even if it is a constant - * string. - */ - ((OFString*)ret)->s->isUTF8 = s->isUTF8; - last = 0; inEntity = NO; for (i = 0; i < length; i++) { if (!inEntity && string[i] == '&') { - [ret appendCStringWithoutUTF8Checking: string + last - length: i - last]; + [ret appendCString: string + last + withLength: i - last]; last = i + 1; inEntity = YES; } else if (inEntity && string[i] == ';') { const char *entity = string + last; size_t entityLength = i - last; if (entityLength == 2 && !memcmp(entity, "lt", 2)) - [ret appendCStringWithoutUTF8Checking: "<" - length: 1]; + [ret appendCString: "<" + withLength: 1]; else if (entityLength == 2 && !memcmp(entity, "gt", 2)) - [ret appendCStringWithoutUTF8Checking: ">" - length: 1]; + [ret appendCString: ">" + withLength: 1]; else if (entityLength == 4 && !memcmp(entity, "quot", 4)) - [ret appendCStringWithoutUTF8Checking: "\"" - length: 1]; + [ret appendCString: "\"" + withLength: 1]; else if (entityLength == 4 && !memcmp(entity, "apos", 4)) - [ret appendCStringWithoutUTF8Checking: "'" - length: 1]; + [ret appendCString: "'" + withLength: 1]; else if (entityLength == 3 && !memcmp(entity, "amp", 3)) - [ret appendCStringWithoutUTF8Checking: "&" - length: 1]; + [ret appendCString: "&" + withLength: 1]; else if (entity[0] == '#') { OFAutoreleasePool *pool; OFString *tmp; pool = [[OFAutoreleasePool alloc] init]; @@ -173,12 +166,12 @@ } if (inEntity) @throw [OFInvalidEncodingException newWithClass: isa]; - [ret appendCStringWithoutUTF8Checking: string + last - length: i - last]; + [ret appendCString: string + last + withLength: i - last]; /* * Class swizzle the string to be immutable. We declared the return type * to be OFString*, so it can't be modified anyway. But not swizzling it * would create a real copy each time -[copy] is called. @@ -199,48 +192,41 @@ string = [self cString]; length = [self cStringLength]; ret = [OFMutableString string]; - /* - * This is safe as we already called -[cString] on self and thus can be - * sure the string is correctly initialized, even if it is a constant - * string. - */ - ((OFString*)ret)->s->isUTF8 = s->isUTF8; - last = 0; inEntity = NO; for (i = 0; i < length; i++) { if (!inEntity && string[i] == '&') { - [ret appendCStringWithoutUTF8Checking: string + last - length: i - last]; + [ret appendCString: string + last + withLength: i - last]; last = i + 1; inEntity = YES; } else if (inEntity && string[i] == ';') { const char *entity = string + last; size_t entityLength = i - last; if (entityLength == 2 && !memcmp(entity, "lt", 2)) - [ret appendCStringWithoutUTF8Checking: "<" - length: 1]; + [ret appendCString: "<" + withLength: 1]; else if (entityLength == 2 && !memcmp(entity, "gt", 2)) - [ret appendCStringWithoutUTF8Checking: ">" - length: 1]; + [ret appendCString: ">" + withLength: 1]; else if (entityLength == 4 && !memcmp(entity, "quot", 4)) - [ret appendCStringWithoutUTF8Checking: "\"" - length: 1]; + [ret appendCString: "\"" + withLength: 1]; else if (entityLength == 4 && !memcmp(entity, "apos", 4)) - [ret appendCStringWithoutUTF8Checking: "'" - length: 1]; + [ret appendCString: "'" + withLength: 1]; else if (entityLength == 3 && !memcmp(entity, "amp", 3)) - [ret appendCStringWithoutUTF8Checking: "&" - length: 1]; + [ret appendCString: "&" + withLength: 1]; else if (entity[0] == '#') { OFAutoreleasePool *pool; OFString *tmp; pool = [[OFAutoreleasePool alloc] init]; @@ -278,12 +264,12 @@ } if (inEntity) @throw [OFInvalidEncodingException newWithClass: isa]; - [ret appendCStringWithoutUTF8Checking: string + last - length: i - last]; + [ret appendCString: string + last + withLength: i - last]; /* * Class swizzle the string to be immutable. We declared the return type * to be OFString*, so it can't be modified anyway. But not swizzling it * would create a real copy each time -[copy] is called.