If an asset POST does not contain well-formed XML, return a 400 (Bad Request) HTTP status rather than simply dropping the request.

This commit is contained in:
Justin Clark-Casey (justincc)
2012-11-22 03:01:57 +00:00
parent 33a4f07c4e
commit 448811ccdd
2 changed files with 38 additions and 3 deletions

View File

@@ -57,14 +57,23 @@ namespace OpenSim.Server.Handlers.Asset
public override byte[] Handle(string path, Stream request,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{
AssetBase asset;
XmlSerializer xs = new XmlSerializer(typeof (AssetBase));
AssetBase asset = (AssetBase) xs.Deserialize(request);
try
{
asset = (AssetBase)xs.Deserialize(request);
}
catch (XmlException)
{
httpResponse.StatusCode = (int)HttpStatusCode.BadRequest;
return null;
}
string[] p = SplitParams(path);
if (p.Length > 1)
{
bool result =
m_AssetService.UpdateContent(p[1], asset.Data);
bool result = m_AssetService.UpdateContent(p[1], asset.Data);
xs = new XmlSerializer(typeof(bool));
return ServerUtils.SerializeResult(xs, result);