#ifndef PROJECT_H_INCLUDED
#define PROJECT_H_INCLUDED
/** Version string. */
-#define PROJECT_H_VERSION "$Id: project.h,v 1.98 2007/07/14 07:31:26 fabiankeil Exp $"
+#define PROJECT_H_VERSION "$Id: project.h,v 1.99 2007/07/21 11:51:36 fabiankeil Exp $"
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/project.h,v $
*
* Revisions :
* $Log: project.h,v $
+ * Revision 1.99 2007/07/21 11:51:36 fabiankeil
+ * As Hal noticed, checking dispatch_cgi() as the last cruncher
+ * looks like a bug if CGI requests are blocked unintentionally,
+ * so don't do it unless the user enabled the new config option
+ * "allow-cgi-request-crunching".
+ *
* Revision 1.98 2007/07/14 07:31:26 fabiankeil
* Add new csp->content_type flag (CT_DECLARED).
*
int dcount; /**< How many parts to this domain? (length of dvec) */
int unanchored; /**< Bitmap - flags are ANCHOR_LEFT and ANCHOR_RIGHT. */
- int port; /**< The port number, or 0 to match all ports. */
+ char *port_list; /**< List of acceptable ports, or NULL to match all ports */
- char *path; /**< The source for the regex. */
- size_t pathlen; /**< ==strlen(path). Needed for prefix matching. FIXME: Now obsolete? */
+ char *path; /**< The source for the regex. */
regex_t *preg; /**< Regex for matching path part */
regex_t *tag_regex; /**< Regex for matching tags */
};
/**
* If you declare a static url_spec, this is the value to initialize it to zero.
*/
-#define URL_SPEC_INITIALIZER { NULL, NULL, NULL, 0, 0, 0, NULL, 0, NULL, NULL }
+#define URL_SPEC_INITIALIZER { NULL, NULL, NULL, 0, 0, NULL, NULL, NULL, NULL }
/**
* Constant for host part matching in URLs. If set, indicates that the start of
-const char urlmatch_rcs[] = "$Id: urlmatch.c,v 1.17 2007/04/15 16:39:21 fabiankeil Exp $";
+const char urlmatch_rcs[] = "$Id: urlmatch.c,v 1.18 2007/07/30 16:42:21 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/urlmatch.c,v $
*
* Revisions :
* $Log: urlmatch.c,v $
+ * Revision 1.18 2007/07/30 16:42:21 fabiankeil
+ * Move the method check into unknown_method()
+ * and loop through the known methods instead
+ * of using a screen-long OR chain.
+ *
* Revision 1.17 2007/04/15 16:39:21 fabiankeil
* Introduce tags as alternative way to specify which
* actions apply to a request. At the moment tags can be
#include "ssplit.h"
#include "miscutil.h"
#include "errlog.h"
+/*
+ * XXX: only for match_portlist() which I will relocate soonish.
+ */
+#include "filters.h"
const char urlmatch_h_rcs[] = URLMATCH_H_VERSION;
}
/* Only reached for URL patterns */
- if ((p = strchr(buf, '/')) != NULL)
+ p = strchr(buf, '/');
+ if (NULL != p)
{
- if (NULL == (url->path = strdup(p)))
+ url->path = strdup(p);
+ if (NULL == url->path)
{
freez(url->spec);
return JB_ERR_MEMORY;
}
- url->pathlen = strlen(url->path);
*p = '\0';
}
else
{
- url->path = NULL;
- url->pathlen = 0;
+ url->path = NULL;
}
if (url->path)
{
return JB_ERR_PARSE;
}
}
- if ((p = strchr(buf, ':')) == NULL)
+
+ p = strchr(buf, ':');
+ if (NULL != p)
{
- url->port = 0;
+ *p++ = '\0';
+ url->port_list = strdup(p);
+ if (NULL == url->port_list)
+ {
+ return JB_ERR_MEMORY;
+ }
}
else
{
- *p++ = '\0';
- url->port = atoi(p);
+ url->port_list = NULL;
}
if (buf[0] != '\0')
freez(url->dbuffer);
freez(url->dvec);
freez(url->path);
+ freez(url->port_list);
if (url->preg)
{
regfree(url->preg);
int url_match(const struct url_spec *pattern,
const struct http_request *url)
{
+ int port_matches;
+ int domain_matches;
+ int path_matches;
+
if (pattern->tag_regex != NULL)
{
/* It's a tag pattern and shouldn't be matched against URLs */
return 0;
}
- return ((pattern->port == 0) || (pattern->port == url->port))
- && ((pattern->dbuffer == NULL) || (domain_match(pattern, url) == 0))
- && ((pattern->path == NULL) ||
- (regexec(pattern->preg, url->path, 0, NULL, 0) == 0)
- );
+ port_matches = (NULL == pattern->port_list) || match_portlist(pattern->port_list, url->port);
+ domain_matches = (NULL == pattern->dbuffer) || (0 == domain_match(pattern, url));
+ path_matches = (NULL == pattern->path) || (0 == regexec(pattern->preg, url->path, 0, NULL, 0));
+
+ return (port_matches && domain_matches && path_matches);
+
}