-
-
Notifications
You must be signed in to change notification settings - Fork 16.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reject routes containing an unescaped space character #2511
Comments
That's fine, but RFC 3986 does not dictate what character may appear in the
I'm OK with throwing on anything that cannot be |
As far as throw vs warning, it would be probably be better to do warning in the existing majors, but even then, there is no proper warning framework for Node.js, so I would say we should deprecate it rather than warn on it (because then that opens us to to throw in 5.x). |
Cool! Implementing a fully-compliant That way we won't reject some invalid targets (e.g. a
As far as I am concerned, it is enough to fix this problem in path-to-regexp and Express 4.x.
Makes sense, let's do that. |
Right, that's what I was getting at. I just gave the spec so you would know when making the blacklist exactly what is on the whitelist :) |
And if it's, for some reason, unfeasible to get a change that works will into |
We have discussed the matter with @dougwilson: Path parameter names don't follow the |
3.20.0, the last 3.x that will ever have an enhancement like this, will be released 2/18. Without an implementation for 3.x before then, this certainly won't make it into the 3.x series. |
I'm bumping this from the 3.x series. |
@dougwilson that's fine 👍 |
Interestingly, this brings up a slightly different conversation that might be interesting to have. Should paths be automatically url encoded? For example, supporting unicode characters and accents in the url? Right now people would need to write out 我 as |
At the moment, when the developer provides a route path containing raw characters that must escaped by HTTP clients, for example a space character, the route is registered by express even though it will never match any request (URL):
Such situation is difficult to troubleshoot, especially if the invalid character was included by mistake.
I am proposing to modify Express and/or path-to-regexp to print a warning when a string path argument contains characters that will be always sent in the encoded form by HTTP clients. RFC3986 allows some characters to be sent either encoded or unencoded. Such characters should be accepted as valid (no error/warning).
In other words, only the following characters may be present in the unencoded form:
ALPHA / DIGIT / "-" / "." / "_" / "~"
":" / "/" / "?" / "#" / "[" / "]" / "@" / "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="
@dougwilson thoughts? StrongLoop can contribute the change, I just want to check with you that such change will be accepted.
I was initially thinking that express should throw an error instead of printing a warning, but since such change may be considered as breaking backwards compatibility, it's probably better to stay with the warning.
/cc @PradnyaBaviskar
The text was updated successfully, but these errors were encountered: