From b7dcec410daa68b70597758930f015a7f631f388 Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Fri, 17 Feb 2012 23:59:15 -0700 Subject: Fixed tons of 'LLXMLTree invalid token' warnings spamming the log and made the warnings we show less confusing --- linden/indra/llcommon/llsdserialize_xml.cpp | 39 +++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 8 deletions(-) (limited to 'linden/indra/llcommon') 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) char c = input.get(); buf[count++] = c; if (is_eol(c)) + { break; + } } return count; } @@ -391,14 +393,36 @@ S32 LLSDXMLParser::Impl::parse(std::istream& input, LLSD& data) if (status == XML_STATUS_ERROR) { - std::string error_string( XML_ErrorString(XML_GetErrorCode( mParser ))); - if ("parsing aborted" != error_string )//end of input + std::string error_string(XML_ErrorString(XML_GetErrorCode( mParser ))); + if (input.gcount() == 0) + { + // nothing to do -- MC + data = LLSD(); + return LLSDParser::PARSE_FAILURE; + } + else if (error_string != "parsing aborted") // end of input { S32 line_number = XML_GetCurrentLineNumber( mParser ); - llwarns << "LLXmlTree parse failed. Line " << line_number << ": " - << error_string << llendl; + // This parses LLCurl::Responder::completedRaw always, even + // when not using XML. We have to do this little ugliness + // in order to make this error message meaningful. + // See Expat's xmlparse.c for the full list of errors -- MC + if (error_string == "not well-formed (invalid token)") + { + std::string text((char*)buffer); + if ((text.find('>') != std::string::npos) || + (text.find('<') != std::string::npos)) + { + llwarns << "LLSDXMLParser::Impl::parse error. Line " << line_number << ": " + << error_string << llendl; + } + break; + } + + llinfos << "Possible LLSDXMLParser::Impl::parse error. Line " << line_number << ": " + << error_string << llendl; } - + // Always break here -- MC break; } } @@ -417,14 +441,13 @@ S32 LLSDXMLParser::Impl::parse(std::istream& input, LLSD& data) ((char*) buffer)[count ? count - 1 : 0] = '\0'; } - data = LLSD(); return LLSDParser::PARSE_FAILURE; } clear_eol(input); data = mResult; - return mParseCount; + return mParseCount; // why return mParseCount?! -- MC } @@ -499,7 +522,7 @@ S32 LLSDXMLParser::Impl::parseLines(std::istream& input, LLSD& data) if ("parsing aborted" != error_string )//end of input { S32 line_number = XML_GetCurrentLineNumber( mParser ); - llwarns << "LLXmlTree parse failed. Line " << line_number << ": " + llwarns << "LLSDXMLParser::Impl::parseLines failed. Line " << line_number << ": " << error_string << llendl; } return LLSDParser::PARSE_FAILURE; -- cgit v1.1