place. Fixes issue #21.
<b>disorder_preferences</b>(5) man page.</p>
</div>
+
+ <h3>Bugs fixed</h3>
+
+ <div class=section>
+
+ <table class=bugs>
+ <tr>
+ <th>ID</th>
+ <th>Description</th>
+ </tr>
+
+ <tr>
+ <td><a href="http://code.google.com/p/disorder/issues/detail?id=21">#21</a></td>
+ <td>CGI should use PATH_INFO more sensibly</td>
+ </tr>
+ </table>
+
+ </div>
</div>
printf("Content-Type: text/html; charset=UTF-8\n");
printf("Status: 404\n");
printf("\n");
- printf("<p>Sorry, PATH_INFO not supported.</p>\n");
+ printf("<p>Sorry, is PATH_INFO not supported."
+ "<a href=\"%s\">Try here instead.</a></p>\n",
+ cgi_sgmlquote(infer_url(0/*!include_path_info*/)));
exit(0);
}
/* Parse CGI arguments */
/* Figure out our URL. This can still be overridden from the config file if
* necessary but it shouldn't be necessary in ordinary installations. */
if(!config->url)
- config->url = infer_url();
+ config->url = infer_url(1/*include_path_info*/);
/* Pick up the cookie, if there is one */
dcgi_get_cookie();
/* Register expansions */
#include "kvp.h"
/** @brief Infer the for the web interface
+ * @param include_path_info 1 to include post-script path, else 0
* @return Inferred URL
*
* See <a href="http://tools.ietf.org/html/rfc3875">RFC 3875</a>.
*/
-char *infer_url(void) {
- const char *scheme = "http", *server, *script, *e, *request_uri;
+char *infer_url(int include_path_info) {
+ const char *scheme = "http", *server, *script, *e, *request_uri, *path_info;
char *url;
int port;
port = 80;
/* Figure out path to ourselves. */
- if((request_uri = getenv("REQUEST_URI"))) {
+ if(include_path_info && (request_uri = getenv("REQUEST_URI"))) {
/* REQUEST_URI is an Apache extexnsion. If it's available it results in
* more accurate self-referencing URLs. */
if((e = strchr(request_uri, '?')))
script = "/";
/* SCRIPT_NAME is not URL-encoded */
script = urlencodestring(script);
+ if(include_path_info && (path_info = getenv("PATH_INFO")))
+ byte_xasprintf((char **)&script, "%s%s",
+ script, urlencodestring(path_info));
}
if(script[0] != '/')
fatal(0, "SCRIPT_NAME does not start with a '/'");
char *query;
};
-char *infer_url(void);
+char *infer_url(int include_path_info);
int parse_url(const char *url, struct url *parsed);
#endif /* URL_H */
setenv("SERVER_NAME", "www.anjou.terraraq.org.uk", 1);
setenv("SERVER_PORT", "80", 1);
setenv("SCRIPT_NAME", "/~richard/env.cgi", 1);
- check_string(infer_url(),
+ check_string(infer_url(1),
"http://www.anjou.terraraq.org.uk/~richard/env.cgi");
setenv("HTTPS", "on", 1);
- check_string(infer_url(),
+ check_string(infer_url(1),
"https://www.anjou.terraraq.org.uk/~richard/env.cgi");
setenv("QUERY_STRING", "foo", 1);
- check_string(infer_url(),
+ check_string(infer_url(1),
"https://www.anjou.terraraq.org.uk/~richard/env.cgi");
setenv("REQUEST_URI", "/~richard/env%2ecgi", 1);
- check_string(infer_url(),
+ check_string(infer_url(1),
"https://www.anjou.terraraq.org.uk/~richard/env%2ecgi");
setenv("REQUEST_URI", "/~richard/env%2ecgi?foo", 1);
- check_string(infer_url(),
+ check_string(infer_url(1),
"https://www.anjou.terraraq.org.uk/~richard/env%2ecgi");
setenv("SERVER_PORT", "8080", 1);
- check_string(infer_url(),
+ check_string(infer_url(1),
"https://www.anjou.terraraq.org.uk:8080/~richard/env%2ecgi");
}