Talk:Ns url2file

From AOLserver Wiki
Jump to navigation Jump to search

What happens to special characters?

If the url contains, e.g., the '+' character or the sequence '%20', does ns_url2file unencode it the same as the underlying page finding code does?

In AOLServer 3.4.2, it doesn't look like it does. Say I request the url '/foo%20bar.html'. If I use a Tcl library function as a "404" handler (using the file-system-as-cache technique), and generate my file via

set file [open "[ns_url2file $url]" w]
puts $file $content
close $file

Then the '$url' is still Not Found on the next request. I'm getting the URL by directly reading the request header (since I'm in a redirection routine, the value of [ns_conn url] is my redirected URL, not the URL originally requested).

Thought I'd ask here since it would be nice if the wiki page got updated with the answer....

Indeed, there's a "bug" in the URL encoding code with respect to "+" and "%20" and whitespace. At some point, we have to "fix" this--but it'll result in a break in backward compatibility and can cause published URLs that expect the previous behavior to become 404's. Perhaps if this is clearly documented and made very clear, it'll be okay to make the change ... your thoughts? --Dossy 09:31, 6 December 2007 (EST)