You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If using the restify server is using the static plugin and the client requests a path that doesn't exist, you'd expect a 404:
% curl -i http://10.99.99.21/docs/no-such-file.html
HTTP/1.1 404 Not Found
Content-Type: application/json
Content-Length: 72
Date: Mon, 26 Jun 2017 22:35:38 GMT
Connection: keep-alive
{
"code": "ResourceNotFound",
"message": "/docs/no-such-file.html"
}
Actual behaviour
However, if the given request path includes percent codes (for URL escaping), that also look like printf codes, then you'll get an InternalError:
{ [InternalError: too few args to sprintf]
jse_shortmsg: '',
jse_info: {},
message: 'too few args to sprintf',
statusCode: 500,
body: { code: 'InternalError', message: 'too few args to sprintf' },
restCode: 'InternalError',
name: 'InternalError' }
(or a crash if your restify server is configured to not use an 'uncaughtException' handler).
This is because:
The 'static' plugin calls: next(new ResourceNotFoundError(err, req.path()));
ResourceNotFoundError is a RestError that is based on verror.WError, which ultimately calls extsprintf.sprintf(<path>).
This blows up because:
> new restify.ResourceNotFoundError('/docs/not-%22such-file.html not found')
Error: too few args to sprintf
...
Repro case
I'll have a test case in the coming PR.
The text was updated successfully, but these errors were encountered:
Restify version: 4.x (I'm running 4.3.0).
Node.js version: v4.8.0.
Expected behaviour
If using the restify server is using the static plugin and the client requests a path that doesn't exist, you'd expect a 404:
Actual behaviour
However, if the given request path includes percent codes (for URL escaping), that also look like printf codes, then you'll get an InternalError:
(or a crash if your restify server is configured to not use an 'uncaughtException' handler).
This is because:
next(new ResourceNotFoundError(err, req.path()));
extsprintf.sprintf(<path>)
.Repro case
I'll have a test case in the coming PR.
The text was updated successfully, but these errors were encountered: