Skip to content

Commit

Permalink
Added content validation before sending
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrienCastex committed May 12, 2017
1 parent dc7ff27 commit 269bcbf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
9 changes: 8 additions & 1 deletion lib/server/commands/Get.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@ function default_1(arg, callback) {
arg.setCode(WebDAVRequest_1.HTTPCodes.NotFound);
else {
arg.setCode(WebDAVRequest_1.HTTPCodes.OK);
arg.response.write(c ? c : new Buffer(0));
var content = c;
if (c === undefined || c === null)
content = new Buffer(0);
else if (c.constructor === Boolean || c.constructor === Number)
content = c.toString();
else
content = c;
arg.response.write(content);
}
callback();
});
Expand Down
11 changes: 10 additions & 1 deletion src/server/commands/Get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,16 @@ export default function(arg : MethodCallArgs, callback)
else
{
arg.setCode(HTTPCodes.OK);
arg.response.write(c ? c : new Buffer(0));

let content : any = c;
if(c === undefined || c === null)
content = new Buffer(0);
else if(c.constructor === Boolean || c.constructor === Number)
content = c.toString()
else
content = c;

arg.response.write(content);
}
callback();
})
Expand Down

0 comments on commit 269bcbf

Please sign in to comment.