[GB.XML.HTML]
* BUG: The HTML parser now really correctly raises an error if the document is incomplete (no doctype/root element). [GB.XML] * BUG: Errors that doesn't give any position in the parsed data are correctly raised now. git-svn-id: svn://localhost/gambas/trunk@5169 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
parent
0d0e541e38
commit
22972ba5ce
2 changed files with 15 additions and 8 deletions
|
@ -340,11 +340,13 @@ void HtmlDocument::setContent(char *content, size_t len) throw(XMLParseException
|
|||
|
||||
//On cherche le début du prologue XML
|
||||
posStart = (char*)memchrs(content, len, "<!DOCTYPE ", 10);
|
||||
throw XMLParseException("No valid Doctype found", 0, 0, 0);
|
||||
if(!posStart) throw XMLParseException("No valid Doctype found", 0, 0, 0);
|
||||
|
||||
DEBUG << (void*)posStart << endl;
|
||||
|
||||
//On cherche la fin du prologue XML
|
||||
posEnd = (char*)memchr(posStart, CHAR_ENDTAG, len - (posStart - content));
|
||||
throw XMLParseException("No valid Doctype found", 0, 0, 0);
|
||||
if(!posEnd) throw XMLParseException("No valid Doctype found", 0, 0, 0);
|
||||
|
||||
//HTML5 ? (<!DOCTYPE html>)
|
||||
html5 = (posEnd - posStart == 4);
|
||||
|
@ -386,6 +388,8 @@ void HtmlDocument::setContent(char *content, size_t len) throw(XMLParseException
|
|||
|
||||
}
|
||||
|
||||
DEBUG << newRoot << endl;
|
||||
|
||||
|
||||
|
||||
free(elements);
|
||||
|
|
|
@ -131,16 +131,13 @@ bool isWhiteSpace(const char s)
|
|||
const void* memchrs(const char *source, size_t lensource, const char *comp, size_t lencomp)
|
||||
{
|
||||
const char *pos = source - 1;
|
||||
register size_t i = 0;
|
||||
do
|
||||
{
|
||||
pos = (char*)(memchr((void*)(pos + 1), ((comp))[0], lensource));
|
||||
if(!pos) return 0;
|
||||
if(pos + lencomp > source + lensource) return 0;
|
||||
for(i = 1; i < lencomp; i++)
|
||||
{
|
||||
if(*((pos + i)) == (comp)[i]) return pos;
|
||||
}
|
||||
if(memcmp(pos, comp, lencomp) != 0) continue;
|
||||
return pos;
|
||||
|
||||
}while(1);
|
||||
}
|
||||
|
@ -194,7 +191,13 @@ XMLParseException::XMLParseException(const char *nerror, const char *data, const
|
|||
|
||||
//Parse error : (errorText) !\n Line 123456789 , Column 123456789 : \n (near)
|
||||
|
||||
if(posFailed == 0) return;
|
||||
if(posFailed == 0)
|
||||
{
|
||||
errorWhat = (char*)malloc(17 + lenError);
|
||||
sprintf(errorWhat, "Parse error : %s !", error);
|
||||
errorWhat[16 + lenError] = 0;
|
||||
return;
|
||||
}
|
||||
if(posFailed > data + lenData || posFailed < data) return;
|
||||
AnalyzeText(data, lenData, posFailed);
|
||||
|
||||
|
|
Loading…
Reference in a new issue