Skip to content
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

Better handling of invalid WSGI path encoding #2340

Open
vytas7 opened this issue Sep 26, 2024 · 3 comments
Open

Better handling of invalid WSGI path encoding #2340

vytas7 opened this issue Sep 26, 2024 · 3 comments

Comments

@vytas7
Copy link
Member

vytas7 commented Sep 26, 2024

Split from #1685: as reported by @rokclimb15, in some cases the WSGI path may Unicode characters that don't comply with the WSGI spec. According to PEP 3333:

On Python platforms where the str or StringType type is in fact Unicode-based (e.g. Jython, IronPython, Python 3, etc.), all “strings” referred to in this specification must contain only code points representable in ISO-8859-1 encoding (\u0000 through \u00FF, inclusive). It is a fatal error for an application to supply strings containing any other Unicode character or code point. Similarly, servers and gateways must not supply strings to an application containing any other Unicode characters.

Per this definition, Falcon actually handles this correctly by exploding with an unhandled error, that is what a fatal error is.

However, if it is not too expensive to catch this error, maybe we could render an HTTP 400 response anyway, providing a helpful message explaining what was the actual problem? Or alternatively, bubble up an unhandled error, but provide a more helpful message explaining what exactly is going on (with a reference to the spec).

@CaselIT
Copy link
Member

CaselIT commented Sep 26, 2024

Shouldn't this more be a 500 error since something in the "backend" is not working as expected, since we are receiving a value outside of backend spec?

@vytas7
Copy link
Member Author

vytas7 commented Sep 26, 2024

Yeah, or maybe just an instance of RuntimeError that has an easier to understand message explaining what the problem is. Because now people might think it is a bug in Falcon.

@CaselIT
Copy link
Member

CaselIT commented Sep 26, 2024

runtime error works too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants