|
|
|
@ -360,6 +360,9 @@ public: |
|
|
|
|
|
|
|
|
|
char* skipSpaces( char* ptr, int mode ) |
|
|
|
|
{ |
|
|
|
|
if (!ptr) |
|
|
|
|
CV_PARSE_ERROR_CPP("Invalid input"); |
|
|
|
|
|
|
|
|
|
int level = 0; |
|
|
|
|
|
|
|
|
|
for(;;) |
|
|
|
@ -441,6 +444,9 @@ public: |
|
|
|
|
|
|
|
|
|
char* parseValue( char* ptr, FileNode& node ) |
|
|
|
|
{ |
|
|
|
|
if (!ptr) |
|
|
|
|
CV_PARSE_ERROR_CPP("Invalid input"); |
|
|
|
|
|
|
|
|
|
FileNode new_elem; |
|
|
|
|
bool have_space = true; |
|
|
|
|
int value_type = node.type(); |
|
|
|
@ -456,6 +462,8 @@ public: |
|
|
|
|
(c == '<' && ptr[1] == '!' && ptr[2] == '-') ) |
|
|
|
|
{ |
|
|
|
|
ptr = skipSpaces( ptr, 0 ); |
|
|
|
|
if (!ptr) |
|
|
|
|
CV_PARSE_ERROR_CPP("Invalid input"); |
|
|
|
|
have_space = true; |
|
|
|
|
c = *ptr; |
|
|
|
|
} |
|
|
|
@ -502,6 +510,8 @@ public: |
|
|
|
|
{ |
|
|
|
|
ptr = fs->parseBase64( ptr, 0, new_elem); |
|
|
|
|
ptr = skipSpaces( ptr, 0 ); |
|
|
|
|
if (!ptr) |
|
|
|
|
CV_PARSE_ERROR_CPP("Invalid input"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ptr = parseTag( ptr, key2, type_name, tag_type ); |
|
|
|
@ -645,6 +655,9 @@ public: |
|
|
|
|
char* parseTag( char* ptr, std::string& tag_name, |
|
|
|
|
std::string& type_name, int& tag_type ) |
|
|
|
|
{ |
|
|
|
|
if (!ptr) |
|
|
|
|
CV_PARSE_ERROR_CPP("Invalid tag input"); |
|
|
|
|
|
|
|
|
|
if( *ptr == '\0' ) |
|
|
|
|
CV_PARSE_ERROR_CPP( "Unexpected end of the stream" ); |
|
|
|
|
|
|
|
|
@ -702,6 +715,8 @@ public: |
|
|
|
|
if( *ptr != '=' ) |
|
|
|
|
{ |
|
|
|
|
ptr = skipSpaces( ptr, CV_XML_INSIDE_TAG ); |
|
|
|
|
if (!ptr) |
|
|
|
|
CV_PARSE_ERROR_CPP("Invalid attribute"); |
|
|
|
|
if( *ptr != '=' ) |
|
|
|
|
CV_PARSE_ERROR_CPP( "Attribute name should be followed by \'=\'" ); |
|
|
|
|
} |
|
|
|
@ -740,6 +755,8 @@ public: |
|
|
|
|
if( c != '>' ) |
|
|
|
|
{ |
|
|
|
|
ptr = skipSpaces( ptr, CV_XML_INSIDE_TAG ); |
|
|
|
|
if (!ptr) |
|
|
|
|
CV_PARSE_ERROR_CPP("Invalid input"); |
|
|
|
|
c = *ptr; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -781,6 +798,8 @@ public: |
|
|
|
|
|
|
|
|
|
// CV_XML_INSIDE_TAG is used to prohibit leading comments
|
|
|
|
|
ptr = skipSpaces( ptr, CV_XML_INSIDE_TAG ); |
|
|
|
|
if (!ptr) |
|
|
|
|
CV_PARSE_ERROR_CPP("Invalid input"); |
|
|
|
|
|
|
|
|
|
if( memcmp( ptr, "<?xml", 5 ) != 0 ) // FIXIT ptr[1..] - out of bounds read without check
|
|
|
|
|
CV_PARSE_ERROR_CPP( "Valid XML should start with \'<?xml ...?>\'" ); |
|
|
|
@ -791,6 +810,8 @@ public: |
|
|
|
|
while( ptr && *ptr != '\0' ) |
|
|
|
|
{ |
|
|
|
|
ptr = skipSpaces( ptr, 0 ); |
|
|
|
|
if (!ptr) |
|
|
|
|
CV_PARSE_ERROR_CPP("Invalid input"); |
|
|
|
|
|
|
|
|
|
if( *ptr != '\0' ) |
|
|
|
|
{ |
|
|
|
|