From 1d7018c8268861148d4f306eac2628f76fb28c21 Mon Sep 17 00:00:00 2001 From: aramis_acg Date: Sun, 17 Jun 2012 12:15:49 +0000 Subject: [PATCH] # fix bug in STEPFileReader, loader fails if string literals contain more than one ". Thanks to Juha Vesanen for the patch. git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@1258 67173fc5-114c-0410-ac8e-9d2fd5bffc1f --- code/STEPFileReader.cpp | 24 ++++++++++++++++-------- revision.h | 2 +- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/code/STEPFileReader.cpp b/code/STEPFileReader.cpp index 7ddfd91c3..66e08fcb5 100644 --- a/code/STEPFileReader.cpp +++ b/code/STEPFileReader.cpp @@ -318,20 +318,28 @@ boost::shared_ptr EXPRESS::DataType::Parse(const char*& else if (*cur == '\'' ) { // string literal const char* start = ++cur; - for(;*cur != '\'';++cur) { - if (*cur == '\0') { + + for(;*cur != '\'';++cur) { + if (*cur == '\0') { throw STEP::SyntaxError("string literal not closed",line); } } - if (cur[1]=='\'') { - for(cur+=2;*cur != '\'';++cur) { - if (*cur == '\0') { - throw STEP::SyntaxError("string literal not closed",line); + + if (cur[1] == '\'') { + // Vesanen: more than 2 escaped ' in one literal! + do { + for(cur += 2;*cur != '\'';++cur) { + if (*cur == '\0') { + throw STEP::SyntaxError("string literal not closed",line); + } } } + while(cur[1] == '\''); } - inout = cur+1; - return boost::make_shared(std::string(start, static_cast(cur-start) )); + + inout = cur + 1; + + return boost::make_shared(std::string(start, static_cast(cur - start))); } else if (*cur == '\"' ) { throw STEP::SyntaxError("binary data not supported yet",line); diff --git a/revision.h b/revision.h index f55c0cc89..03665b4ba 100644 --- a/revision.h +++ b/revision.h @@ -1 +1 @@ -#define SVNRevision 1154 +#define SVNRevision 1257