From 4c741ce8537369b033635f5d14d1fe4920b7326b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Fri, 6 Jun 2014 11:16:22 +0200 Subject: [PATCH] [core] expose request.raw_path as condition variable --- doc/core_config.xml | 1 + doc/core_pattern.xml | 2 +- include/lighttpd/condition.h | 1 + src/main/condition.c | 8 ++++++++ 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/doc/core_config.xml b/doc/core_config.xml index 7ec9836..bec7856 100644 --- a/doc/core_config.xml +++ b/doc/core_config.xml @@ -299,6 +299,7 @@ | request.remoteip | ip address of the client | | request.remoteport | port number of the client, -1 for unix sockets | | request.path | the _path_ part of the requested url. not including the querystring. | + | request.raw_path | the raw _path_ part (not urldecoded, not simplified) of the requested url. not including the querystring. | | request.host | requested hostname | | request.scheme | scheme of the request. "http" or "https" | | request.query | the _querystring_ of the requested url | diff --git a/doc/core_pattern.xml b/doc/core_pattern.xml index cfad7b9..cff3c83 100644 --- a/doc/core_pattern.xml +++ b/doc/core_pattern.xml @@ -14,7 +14,7 @@ * simple text. can contain special characters $ and % only when they are escaped with \ - remember, that the \ has to be escaped too for the config, so you'll probably have to use \\ to escape. You are allowed to escape ? too (used for special "split" in rewrite). * "%" capture references (previous matching regular expression conditional); either followed by a single digit, or a range (see below for range syntax) * "$" capture references (depends on action); either followed by a single digit, or a range (see below for range syntax) - * "%" references to "condition variables":core_config.html#core_connfig__condition_vars, for example: @%{req.path}@; the conditional can be prefixed with "enc:" (@%{enc:req.path}@), in which case the value will be urlencoded. + * "%" references to "condition variables":core_config.html#core_config__condition_vars, for example: @%{req.path}@; the conditional can be prefixed with "enc:" (@%{enc:req.path}@), in which case the value will be urlencoded. diff --git a/include/lighttpd/condition.h b/include/lighttpd/condition.h index 2a39848..96aeec0 100644 --- a/include/lighttpd/condition.h +++ b/include/lighttpd/condition.h @@ -42,6 +42,7 @@ typedef enum { LI_COMP_REQUEST_REMOTEIP, LI_COMP_REQUEST_REMOTEPORT, LI_COMP_REQUEST_PATH, + LI_COMP_REQUEST_RAW_PATH, LI_COMP_REQUEST_HOST, LI_COMP_REQUEST_SCHEME, LI_COMP_REQUEST_QUERY_STRING, diff --git a/src/main/condition.c b/src/main/condition.c index 932c687..5db0d84 100644 --- a/src/main/condition.c +++ b/src/main/condition.c @@ -7,6 +7,7 @@ static const liConditionValueType cond_value_hints[] = { /* LI_COMP_REQUEST_REMOTEIP: */ LI_COND_VALUE_HINT_SOCKADDR, /* LI_COMP_REQUEST_REMOTEPORT: */ LI_COND_VALUE_HINT_NUMBER, /* LI_COMP_REQUEST_PATH: */ LI_COND_VALUE_HINT_STRING, + /* LI_COMP_REQUEST_RAW_PATH: */ LI_COND_VALUE_HINT_STRING, /* LI_COMP_REQUEST_HOST: */ LI_COND_VALUE_HINT_ANY, /* LI_COMP_REQUEST_SCHEME: */ LI_COND_VALUE_HINT_STRING, /* LI_COMP_REQUEST_QUERY_STRING: */ LI_COND_VALUE_HINT_ANY, @@ -95,6 +96,10 @@ liHandlerResult li_condition_get_value(GString *tmpstr, liVRequest *vr, liCondit res->match_type = LI_COND_VALUE_HINT_STRING; res->data.str = vr->request.uri.path->str; break; + case LI_COMP_REQUEST_RAW_PATH: + res->match_type = LI_COND_VALUE_HINT_STRING; + res->data.str = vr->request.uri.raw_path->str; + break; case LI_COMP_REQUEST_HOST: res->match_type = LI_COND_VALUE_HINT_STRING; res->data.str = vr->request.uri.host->str; @@ -465,6 +470,7 @@ const char* li_cond_lvalue_to_string(liCondLValue t) { case LI_COMP_REQUEST_REMOTEIP: return "request.remoteip"; case LI_COMP_REQUEST_REMOTEPORT: return "request.remoteport"; case LI_COMP_REQUEST_PATH: return "request.path"; + case LI_COMP_REQUEST_RAW_PATH: return "request.raw_path"; case LI_COMP_REQUEST_HOST: return "request.host"; case LI_COMP_REQUEST_SCHEME: return "request.scheme"; case LI_COMP_REQUEST_QUERY_STRING: return "request.query"; @@ -512,6 +518,8 @@ liCondLValue li_cond_lvalue_from_string(const gchar *str, guint len) { return LI_COMP_REQUEST_REMOTEPORT; else if (strncmp(c, "path", len) == 0) return LI_COMP_REQUEST_PATH; + else if (strncmp(c, "raw_path", len) == 0) + return LI_COMP_REQUEST_RAW_PATH; else if (strncmp(c, "host", len) == 0) return LI_COMP_REQUEST_HOST; else if (strncmp(c, "scheme", len) == 0)