Index: src/OFXMLParser.m
==================================================================
--- src/OFXMLParser.m
+++ src/OFXMLParser.m
@@ -176,12 +176,13 @@
case OF_XMLPARSER_OUTSIDE_TAG:
if (buf[i] == '<') {
len = i - last;
if (len > 0)
- [cache appendCString: buf + last
- withLength: len];
+ [cache appendCStringWithoutUTF8Checking:
+ buf + last
+ length: len];
if ([cache cStringLength] > 0) {
OFString *str;
pool = [[OFAutoreleasePool alloc] init];
@@ -219,12 +220,13 @@
const char *cache_c, *tmp;
size_t cache_len;
len = i - last;
if (len > 0)
- [cache appendCString: buf + last
- withLength: len];
+ [cache appendCStringWithoutUTF8Checking:
+ buf + last
+ length: len];
cache_c = [cache cString];
cache_len = [cache cStringLength];
if ((tmp = memchr(cache_c, ':',
cache_len)) != NULL) {
@@ -300,12 +302,13 @@
size_t cache_len;
OFString *ns;
len = i - last;
if (len > 0)
- [cache appendCString: buf + last
- withLength: len];
+ [cache appendCStringWithoutUTF8Checking:
+ buf + last
+ length: len];
cache_c = [cache cString];
cache_len = [cache cStringLength];
if ((tmp = memchr(cache_c, ':',
cache_len)) != NULL) {
@@ -415,12 +418,13 @@
const char *cache_c, *tmp;
size_t cache_len;
len = i - last;
if (len > 0)
- [cache appendCString: buf + last
- withLength: len];
+ [cache appendCStringWithoutUTF8Checking:
+ buf + last
+ length: len];
cache_c = [cache cString];
cache_len = [cache cStringLength];
if ((tmp = memchr(cache_c, ':',
@@ -461,12 +465,13 @@
OFString *attr_ns;
OFString *attr_val;
len = i - last;
if (len > 0)
- [cache appendCString: buf + last
- withLength: len];
+ [cache appendCStringWithoutUTF8Checking:
+ buf + last
+ length: len];
pool = [[OFAutoreleasePool alloc] init];
attr_ns = namespace_for_prefix(
(attrPrefix != nil ? attrPrefix : prefix),
namespaces);
@@ -538,22 +543,27 @@
if (buf[i] == '-')
state = OF_XMLPARSER_IN_COMMENT_4;
break;
case OF_XMLPARSER_IN_COMMENT_4:
if (buf[i] == '-') {
- size_t cache_len;
-
- [cache appendCString: buf + last
- withLength: i - last];
- cache_len = [cache length];
+ OFMutableString *comment;
+ size_t len;
pool = [[OFAutoreleasePool alloc] init];
- [cache removeCharactersFromIndex: cache_len - 1
- toIndex: cache_len];
- [cache removeLeadingAndTrailingWhitespaces];
+
+ [cache
+ appendCStringWithoutUTF8Checking: buf + last
+ length: i - last];
+
+ comment = [[cache mutableCopy] autorelease];
+ len = [comment length];
+
+ [comment removeCharactersFromIndex: len - 1
+ toIndex: len];
+ [comment removeLeadingAndTrailingWhitespaces];
[delegate xmlParser: self
- foundComment: cache];
+ foundComment: comment];
[pool release];
[cache setToCString: ""];
last = i + 1;
@@ -566,12 +576,12 @@
}
len = size - last;
/* In OF_XMLPARSER_IN_TAG, there can be only spaces */
if (len > 0 && state != OF_XMLPARSER_IN_TAG)
- [cache appendCString: buf + last
- withLength: len];
+ [cache appendCStringWithoutUTF8Checking: buf + last
+ length: len];
}
- (OFString*)foundUnknownEntityNamed: (OFString*)entity
{
return [delegate xmlParser: self
Index: tests/OFXMLParserTests.m
==================================================================
--- tests/OFXMLParserTests.m
+++ tests/OFXMLParserTests.m
@@ -282,11 +282,11 @@
const char *str = "foo\n"
"\n"
" \n"
" \n"
" \n"
- " \n"
" \n"
" \n"
" \n"
" \n"