http property browser: don't crash on invalid nodes
Don't expect users to always pass valid node names or paths
This commit is contained in:
parent
7c2ce9acf7
commit
64c393d022
1 changed files with 19 additions and 3 deletions
|
@ -240,16 +240,26 @@ bool PropertyUriHandler::handleGetRequest( const HTTPRequest & request, HTTPResp
|
|||
// update leaf
|
||||
string value = request.RequestVariables.get("value");
|
||||
SG_LOG(SG_NETWORK,SG_INFO, "httpd: setting " << propertyPath << " to '" << value << "'" );
|
||||
try {
|
||||
fgSetString( propertyPath.c_str(), value );
|
||||
}
|
||||
catch( string & s ) {
|
||||
SG_LOG(SG_NETWORK,SG_ALERT, "httpd: setting " << propertyPath << " to '" << value << "' failed: " << s );
|
||||
}
|
||||
}
|
||||
|
||||
if( request.RequestVariables.get("submit") == "set" ) {
|
||||
for( HTTPRequest::StringMap::const_iterator it = request.RequestVariables.begin(); it != request.RequestVariables.end(); ++it ) {
|
||||
if( it->first == "submit" ) continue;
|
||||
string pp = propertyPath + "/" + it->first;
|
||||
SG_LOG(SG_NETWORK,SG_INFO, "httpd: setting " << pp << " to '" << it->second << "'" );
|
||||
try {
|
||||
fgSetString( pp, it->second );
|
||||
}
|
||||
catch( string & s ) {
|
||||
SG_LOG(SG_NETWORK,SG_ALERT, "httpd: setting " << pp << " to '" << it->second << "' failed: " << s );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// build the response
|
||||
|
@ -273,7 +283,13 @@ bool PropertyUriHandler::handleGetRequest( const HTTPRequest & request, HTTPResp
|
|||
DOMNode * body = new DOMNode( "body" );
|
||||
html->addChild( body );
|
||||
|
||||
SGPropertyNode_ptr node = fgGetNode( string("/") + propertyPath );
|
||||
SGPropertyNode_ptr node;
|
||||
try {
|
||||
node = fgGetNode( string("/") + propertyPath );
|
||||
}
|
||||
catch( string & s ) {
|
||||
SG_LOG(SG_NETWORK,SG_ALERT, "httpd: reading '" << propertyPath << "' failed: " << s );
|
||||
}
|
||||
if( false == node.valid() ) {
|
||||
DOMNode * headline = new DOMNode( "h3" );
|
||||
body->addChild( headline );
|
||||
|
|
Loading…
Add table
Reference in a new issue