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

Unneeded escaping in $REQUEST_URI variable #58

Open
vbezhenar opened this issue Sep 26, 2015 · 1 comment
Open

Unneeded escaping in $REQUEST_URI variable #58

vbezhenar opened this issue Sep 26, 2015 · 1 comment

Comments

@vbezhenar
Copy link

I want to serve my site from https://example.com and redirect other requests to this location. I made the following httpd.conf:

server "default" {
        listen on 1.2.3.4 port 80
        block return 301 "https://vbezhenar.com$REQUEST_URI"
}

server "vbezhenar.com" {
        listen on 1.2.3.4 tls port 443
        tls certificate "/etc/ssl/example.com.crt"
        tls key "/etc/ssl/private/example.com.key"
}

now I'm issuing request to the url http://example.com/path?a=b&c=d :

GET /path?a=b&c=d HTTP/1.1
Host: example.com

and receiving redirect to https://example.com/path%3Fa=b%26c=d

HTTP/1.0 301 Moved Permanently
Date: Sat, 26 Sep 2015 15:12:44 GMT
Server: OpenBSD httpd
Connection: close
Content-Type: text/html
Content-Length: 374
Location: https://example.com/path%3Fa=b%26c=d

This is wrong redirect: it URI-encodes "?" and "&" corrupting initial request.

There should be some way to preserve request URI.

@cnst
Copy link

cnst commented May 14, 2016

Can confirm: http://marc.info/?l=openbsd-cvs&m=146307679702630&w=2.

This is because http://bxr.su/o/usr.sbin/httpd/server_http.c#server_expand_http always calls http://bxr.su/o/usr.sbin/httpd/httpd.c#url_encode on http_query, thus you'll keep getting it re-encoded all over again with each subsequent Location.

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

2 participants