mod_alias silently drops aliases containing a ~
In my configuration, I want to map a location to a script. The following would accomplish this:
alias.url = ("/~dave/logs/search" => "/home/dave/bot/logs/logsearch.py")
However, this does not work: A request for /~dave/logs/search 404s. Changing the above to:
alias.url = ("/dave/logs/search" => "/home/dave/bot/logs/logsearch.py")
results in the alias working perfectly.
For the purposes of this little exercise, mod_userdir was disabled. My original plan was of course to have this override one path within a userdir-enabled path, but this bug is present even without mod_userdir.
Updated by Anonymous over 13 years ago
The following workaround is usable:
url.rewrite = ("^/~dave/logs/search" => "/random_gibberish_url")
alias.url = ("/random_gibberish_url" => "/home/dave/bot/logs/logsearch.py")
Apparently mod_rewrite does not suffer from the same issues, and can rewrite the tilded URL to some internal identifier (I used
pwgen -s 42 to generate one). Then, mod_alias successfully maps that internal identifier to a script, and with further configuration mod_cgi can execute it.
Updated by stbuehler over 13 years ago
I couldn't reproduce your problem, perhaps you should post a minimal config which reproduces your problem.
I even created a extra testcase to test this, see http://repo.or.cz/w/lighttpd.git?a=shortlog;h=refs/heads/lighttpd-1.4.x-stbuehler
Updated by moo over 13 years ago
- Status changed from Fixed to Need Feedback
- Resolution deleted (
i can reproduce this bug when pressing "enter" in firefox address bar, request is sent as "%7e" or "%7E". This issue affects mod_alias/redirect/rewrite as they match on raw url instead of clean url (lighttpd 1.5)
Updated by stbuehler about 13 years ago
- Status changed from Need Feedback to Fixed
- Resolution set to worksforme
And i checked it again...:
server.modules = ( "mod_alias", ) server.document-root = var.cwd + "/default/htdocs" server.port = 8081 alias.url = ( "/~user1/test.txt" => var.cwd + "/default/htdocs/test.txt" )
There is of course a test.txt in ./default/htdocs/
Now, i can get other files in that directory with http://localhost:8081/otherfile but not with http://localhost:8081/~user1/otherfile (as expected), but http://localhost:8081/~user1/test.txt works, with and without %7e encoding:
$ curl -v http://localhost:8081/%7euser1/test.txt * About to connect() to localhost port 8081 (#0) * Trying 127.0.0.1... connected * Connected to localhost (127.0.0.1) port 8081 (#0) > GET /%7euser1/test.txt HTTP/1.1 > User-Agent: curl/7.18.2 (i486-pc-linux-gnu) libcurl/7.18.2 OpenSSL/0.9.8g zlib/126.96.36.199 libidn/1.8 libssh2/0.18 > Host: localhost:8081 > Accept: */* > < HTTP/1.1 200 OK < Content-Type: application/octet-stream < Accept-Ranges: bytes < Content-Length: 328 < Date: Mon, 22 Sep 2008 09:48:45 GMT < Server: lighttpd/1.4.19 < Hi! 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef * Connection #0 to host localhost left intact * Closing connection #0
For rewrite/redirect see #1720
Also available in: Atom