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

Panic when CGI script is served at the root #18

Open
chkno opened this issue Nov 20, 2022 · 1 comment
Open

Panic when CGI script is served at the root #18

chkno opened this issue Nov 20, 2022 · 1 comment

Comments

@chkno
Copy link

chkno commented Nov 20, 2022

When a CGI script is configured to be at the root of a domain -- when the whole website is served from one CGI script -- cgi/src/lib.rs:304:21 panics:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: http::Error(InvalidUri(Empty))', 
/build/foo-0.1.0-vendor.tar.gz/cgi/src/lib.rs:304:21`

It looks like this is caused by SCRIPT_NAME being empty. There isn't a script name when the script is serving the whole domain.

I found this note, which seems to be interpreting RFC 3875 section 3.3, which makes a promise that

http://$SERVER_NAME:$SERVER_PORT$SCRIPT_NAME$PATH_INFO will always be an accessible URL that points to the current script

So if the script is serving http://example.com:80/ , there's only the one / character at the end there to be split between SCRIPT_NAME and PATH_INFO. Apache puts it in PATH_INFO -- it calls the CGI script with PATH_INFO=/ and SCRIPT_NAME= (empty). An empty SCRIPT_NAME causes version 0.6.0 of this library to panic, but is a valid invocation of a CGI script.

@chkno
Copy link
Author

chkno commented Nov 20, 2022

Should PATH_INFO be included in the uri?? That fixes this problem and makes this library behave more like I (as a CGI novice) expect it to, but seems like a big change?

A more narrow fix would be to just use / as the uri when SCRIPT_NAME is empty.

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

No branches or pull requests

1 participant