Removing null characters from xml parser input to avoid parsing failures

pull/261/head
Léo Terziman 2013-11-26 16:35:11 +01:00
parent e2676ec176
commit bac6b34504
2 changed files with 12 additions and 2 deletions

View File

@ -81,12 +81,22 @@ public:
// Map the buffer into memory and convert it to UTF8. IrrXML provides its // Map the buffer into memory and convert it to UTF8. IrrXML provides its
// own conversion, which is merely a cast from uintNN_t to uint8_t. Thus, // own conversion, which is merely a cast from uintNN_t to uint8_t. Thus,
// it is not suitable for our purposes and we have to do it BEFORE IrrXML // it is not suitable for our purposes and we have to do it BEFORE IrrXML
// gets the buffer. Sadly, this forces as to map the whole file into // gets the buffer. Sadly, this forces us to map the whole file into
// memory. // memory.
data.resize(stream->FileSize()); data.resize(stream->FileSize());
stream->Read(&data[0],data.size(),1); stream->Read(&data[0],data.size(),1);
// Remove null characters from the input sequence otherwise the parsing will utterly fail
unsigned int size = 0;
unsigned int size_max = data.size();
for(unsigned int i = 0; i < size_max; i++) {
if(data[i] != '\0') {
data[size++] = data[i];
}
}
data.resize(size);
BaseImporter::ConvertToUTF8(data); BaseImporter::ConvertToUTF8(data);
} }

View File

@ -215,7 +215,7 @@ private:
{ {
char_type* start = P; char_type* start = P;
// more forward until '<' found // move forward until '<' found
while(*P != L'<' && *P) while(*P != L'<' && *P)
++P; ++P;