diff options
-rw-r--r-- | linden/indra/llcommon/llsdserialize_xml.cpp | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/linden/indra/llcommon/llsdserialize_xml.cpp b/linden/indra/llcommon/llsdserialize_xml.cpp index dab6c1d..3545309 100644 --- a/linden/indra/llcommon/llsdserialize_xml.cpp +++ b/linden/indra/llcommon/llsdserialize_xml.cpp | |||
@@ -358,7 +358,9 @@ static unsigned get_till_eol(std::istream& input, char *buf, unsigned bufsize) | |||
358 | char c = input.get(); | 358 | char c = input.get(); |
359 | buf[count++] = c; | 359 | buf[count++] = c; |
360 | if (is_eol(c)) | 360 | if (is_eol(c)) |
361 | { | ||
361 | break; | 362 | break; |
363 | } | ||
362 | } | 364 | } |
363 | return count; | 365 | return count; |
364 | } | 366 | } |
@@ -391,14 +393,36 @@ S32 LLSDXMLParser::Impl::parse(std::istream& input, LLSD& data) | |||
391 | 393 | ||
392 | if (status == XML_STATUS_ERROR) | 394 | if (status == XML_STATUS_ERROR) |
393 | { | 395 | { |
394 | std::string error_string( XML_ErrorString(XML_GetErrorCode( mParser ))); | 396 | std::string error_string(XML_ErrorString(XML_GetErrorCode( mParser ))); |
395 | if ("parsing aborted" != error_string )//end of input | 397 | if (input.gcount() == 0) |
398 | { | ||
399 | // nothing to do -- MC | ||
400 | data = LLSD(); | ||
401 | return LLSDParser::PARSE_FAILURE; | ||
402 | } | ||
403 | else if (error_string != "parsing aborted") // end of input | ||
396 | { | 404 | { |
397 | S32 line_number = XML_GetCurrentLineNumber( mParser ); | 405 | S32 line_number = XML_GetCurrentLineNumber( mParser ); |
398 | llwarns << "LLXmlTree parse failed. Line " << line_number << ": " | 406 | // This parses LLCurl::Responder::completedRaw always, even |
399 | << error_string << llendl; | 407 | // when not using XML. We have to do this little ugliness |
408 | // in order to make this error message meaningful. | ||
409 | // See Expat's xmlparse.c for the full list of errors -- MC | ||
410 | if (error_string == "not well-formed (invalid token)") | ||
411 | { | ||
412 | std::string text((char*)buffer); | ||
413 | if ((text.find('>') != std::string::npos) || | ||
414 | (text.find('<') != std::string::npos)) | ||
415 | { | ||
416 | llwarns << "LLSDXMLParser::Impl::parse error. Line " << line_number << ": " | ||
417 | << error_string << llendl; | ||
418 | } | ||
419 | break; | ||
420 | } | ||
421 | |||
422 | llinfos << "Possible LLSDXMLParser::Impl::parse error. Line " << line_number << ": " | ||
423 | << error_string << llendl; | ||
400 | } | 424 | } |
401 | 425 | // Always break here -- MC | |
402 | break; | 426 | break; |
403 | } | 427 | } |
404 | } | 428 | } |
@@ -417,14 +441,13 @@ S32 LLSDXMLParser::Impl::parse(std::istream& input, LLSD& data) | |||
417 | ((char*) buffer)[count ? count - 1 : 0] = '\0'; | 441 | ((char*) buffer)[count ? count - 1 : 0] = '\0'; |
418 | } | 442 | } |
419 | 443 | ||
420 | |||
421 | data = LLSD(); | 444 | data = LLSD(); |
422 | return LLSDParser::PARSE_FAILURE; | 445 | return LLSDParser::PARSE_FAILURE; |
423 | } | 446 | } |
424 | 447 | ||
425 | clear_eol(input); | 448 | clear_eol(input); |
426 | data = mResult; | 449 | data = mResult; |
427 | return mParseCount; | 450 | return mParseCount; // why return mParseCount?! -- MC |
428 | } | 451 | } |
429 | 452 | ||
430 | 453 | ||
@@ -499,7 +522,7 @@ S32 LLSDXMLParser::Impl::parseLines(std::istream& input, LLSD& data) | |||
499 | if ("parsing aborted" != error_string )//end of input | 522 | if ("parsing aborted" != error_string )//end of input |
500 | { | 523 | { |
501 | S32 line_number = XML_GetCurrentLineNumber( mParser ); | 524 | S32 line_number = XML_GetCurrentLineNumber( mParser ); |
502 | llwarns << "LLXmlTree parse failed. Line " << line_number << ": " | 525 | llwarns << "LLSDXMLParser::Impl::parseLines failed. Line " << line_number << ": " |
503 | << error_string << llendl; | 526 | << error_string << llendl; |
504 | } | 527 | } |
505 | return LLSDParser::PARSE_FAILURE; | 528 | return LLSDParser::PARSE_FAILURE; |