diff --git a/src/nhttpd/yhttpd_core/yhook.cpp b/src/nhttpd/yhttpd_core/yhook.cpp index 4b4f7118a..197da9cc1 100644 --- a/src/nhttpd/yhttpd_core/yhook.cpp +++ b/src/nhttpd/yhttpd_core/yhook.cpp @@ -368,10 +368,14 @@ void CyhookHandler::printf(const char *fmt, ...) { TOutType CyhookHandler::checkOutput() { // get outType outType = plain; // plain - if (ParamList["format"] == "json" || !(ParamList["json"].empty()) ) - outType = json; - else if (ParamList["format"] == "xml" || !(ParamList["xml"].empty()) ) - outType = xml; + if(!(ParamList.empty())) { + if ((ParamList.find("format") != ParamList.end() && ParamList["format"] == "json") + || (ParamList.find("json") != ParamList.end() && !(ParamList["json"].empty())) ) + outType = json; + else if ((ParamList.find("format") != ParamList.end() && ParamList["format"] == "xml") + || (ParamList.find("xml") != ParamList.end() && !(ParamList["xml"].empty())) ) + outType = xml; + } return outType; } //-----------------------------------------------------------------------------