@@ -192,10 +192,20 @@ - (void)parseBuffer: (const char*)buf withSize: (size_t)size { size_t i, last = 0; + + if (finishedParsing) { + for (i = 0; i < size; i++) + if (buf[i] != ' ' && buf[i] != '\t' && + buf[i] != '\n' && buf[i] != '\r') + @throw [OFMalformedXMLException + newWithClass: isa]; + + return; + } for (i = 0; i < size; i++) lookup_table[state](self, selectors[state], buf, &i, &last); /* In OF_XMLPARSER_IN_TAG, there can be only spaces */ @@ -497,10 +507,13 @@ *last = *i + 1; state = (buf[*i] == '>' ? OF_XMLPARSER_OUTSIDE_TAG : OF_XMLPARSER_EXPECT_SPACE_OR_CLOSE); + + if ([previous count] == 0) + finishedParsing = YES; } /* Inside a tag, name found */ - (void)_parseInTagWithBuffer: (const char*)buf i: (size_t*)i @@ -877,10 +890,15 @@ level--; } *last = *i + 1; } + +- (BOOL)finishedParsing +{ + return finishedParsing; +} - (OFString*)string: (OFString*)string containsUnknownEntityNamed: (OFString*)entity { #if defined(OF_HAVE_PROPERTIES) && defined(OF_HAVE_BLOCKS)