-const char urlmatch_rcs[] = "$Id: urlmatch.c,v 1.46 2009/02/11 19:31:32 fabiankeil Exp $";
+const char urlmatch_rcs[] = "$Id: urlmatch.c,v 1.47 2009/03/02 19:18:10 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/urlmatch.c,v $
*
* Revisions :
* $Log: urlmatch.c,v $
+ * Revision 1.47 2009/03/02 19:18:10 fabiankeil
+ * Streamline parse_http_request()'s prototype. As
+ * cparser pointed out it doesn't actually use csp.
+ *
* Revision 1.46 2009/02/11 19:31:32 fabiankeil
* Reject request lines that end with neither HTTP/1.0 nor HTTP/1.1.
*
host = buf;
}
+ /* Move after hostname before port number */
+ if (*host == '[')
+ {
+ /* Numeric IPv6 address delimited by brackets */
+ host++;
+ port = strchr(host, ']');
+
+ if (port == NULL)
+ {
+ /* Missing closing bracket */
+ freez(buf);
+ return JB_ERR_PARSE;
+ }
+
+ *port++='\0';
+
+ if (*port == '\0')
+ {
+ port = NULL;
+ }
+ else if (*port != ':')
+ {
+ /* Garbage after closing bracket */
+ freez(buf);
+ return JB_ERR_PARSE;
+ }
+ }
+ else
+ {
+ /* Plain non-escaped hostname */
+ port = strchr(host, ':');
+ }
+
/* check if url contains port */
- port = strchr(host, ':');
if (port != NULL)
{
/* Contains port */
*p = '\0';
}
- p = strchr(buf, ':');
+ /* XXX: IPv6 numeric hostname contains colons, thus we need to delimit the
+ * hostname before real port separator. Because brackets are used in
+ * hostname matching on lower layer, we can't use it. I decided to use
+ * angle brackets '<' '>' instead. */
+ if (buf[0] == '<' && NULL != (p = strchr(buf + 1, '>')))
+ {
+ *p++ = '\0';
+ buf++;
+
+ if (*p == '\0')
+ {
+ /* Only IPv6 address without port number */
+ p = NULL;
+ }
+ else if (*p != ':')
+ {
+ /* Garbage after address delimiter */
+ return JB_ERR_PARSE;
+ }
+ }
+ else
+ {
+ p = strchr(buf, ':');
+ }
+
if (NULL != p)
{
*p++ = '\0';
Local Variables:
tab-width: 3
end:
+
+ vim:softtabstop=3 shiftwidth=3
*/