You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by mt...@apache.org on 2003/04/21 10:20:35 UTC
cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_uriEnv.c jk_uriMap.c
mturk 2003/04/21 01:20:35
Modified: jk/native2/common jk_uriEnv.c jk_uriMap.c
Log:
Use the wild char matching funtions instead of existing one.
It enables more general mappings using multiple asterix or
question mark chars.
Revision Changes Path
1.49 +20 -77 jakarta-tomcat-connectors/jk/native2/common/jk_uriEnv.c
Index: jk_uriEnv.c
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_uriEnv.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -r1.48 -r1.49
--- jk_uriEnv.c 18 Apr 2003 08:50:57 -0000 1.48
+++ jk_uriEnv.c 21 Apr 2003 08:20:35 -0000 1.49
@@ -347,8 +347,6 @@
static int jk2_uriEnv_init(jk_env_t *env, jk_uriEnv_t *uriEnv)
{
-/* int err; */
- char *asterisk;
char *uri=uriEnv->pool->pstrdup( env, uriEnv->pool, uriEnv->uri);
/* Set the worker */
@@ -415,10 +413,8 @@
return JK_ERR;
}
- asterisk = strchr(uri, '*');
-
/* set the mapping type */
- if (!asterisk) {
+ if (!jk2_is_wildmatch(uri)) {
/* Something like: JkMount /login/j_security_check ajp13 */
uriEnv->prefix = uri;
uriEnv->prefix_len =strlen( uriEnv->prefix );
@@ -447,83 +443,30 @@
return JK_OK;
}
- /*
- * We have an * in the uri. Check the type.
- * - /context/ASTERISK.suffix
- * - /context/PREFIX/ASTERISK
- *
- * Unsupported:
- * - context path: /ASTERISK/prefix
- * - general suffix rule /context/prefix/ASTERISKsuffix
- */
- asterisk--;
- if ('/' == asterisk[0]) {
- if ( 0 == strncmp("/*/",uri,3) ) {
- /* general context path */
- asterisk[1] = '\0';
- uriEnv->suffix = asterisk + 2;
- uriEnv->prefix = uri;
- uriEnv->prefix_len =strlen( uriEnv->prefix );
- uriEnv->match_type = MATCH_TYPE_CONTEXT_PATH;
-
- if( uriEnv->mbean->debug > 0 ) {
- env->l->jkLog(env, env->l, JK_LOG_DEBUG,
- "Into jk_uri_worker_map_t::uri_worker_map_open, "
- "general context path rule %s * %s -> %s was added\n",
- uri, asterisk + 2, uriEnv->workerName);
- }
- } else if ('.' == asterisk[2]) {
- /* suffix rule: /context/ASTERISK.extension */
- asterisk[1] = '\0';
- asterisk[2] = '\0';
- uriEnv->prefix = uri;
- uriEnv->prefix_len =strlen( uriEnv->prefix );
- uriEnv->suffix = asterisk + 3;
- uriEnv->suffix_len = strlen(asterisk + 3);
- uriEnv->match_type = MATCH_TYPE_SUFFIX;
- if( uriEnv->mbean->debug > 0 ) {
- env->l->jkLog(env, env->l, JK_LOG_DEBUG,
- "uriEnv.init() suffix mapping %s .%s=%s was added\n",
- uriEnv->prefix, uriEnv->suffix, uriEnv->workerName);
- }
- } else if ('\0' != asterisk[2]) {
- /* general suffix rule /context/prefix/ASTERISKextraData */
- asterisk[1] = '\0';
- uriEnv->suffix = asterisk + 2;
- uriEnv->suffix_len = strlen(asterisk + 2);
- uriEnv->prefix = uri;
- uriEnv->prefix_len =strlen( uriEnv->prefix );
- uriEnv->match_type = MATCH_TYPE_GENERAL_SUFFIX;
- if( uriEnv->mbean->debug > 0 ) {
- env->l->jkLog(env, env->l, JK_LOG_DEBUG,
- "uriEnv.init() general suffix mapping %s.%s=%s\n",
- uri, asterisk + 2, uriEnv->workerName);
- }
- } else {
- /* context based /context/prefix/ASTERISK */
- asterisk[1] = '\0';
-
- uriEnv->suffix = NULL;
- uriEnv->prefix = uri;
- uriEnv->prefix_len =strlen( uriEnv->prefix );
- uriEnv->match_type = MATCH_TYPE_PREFIX;
- if( uriEnv->mbean->debug > 0 ) {
- env->l->jkLog(env, env->l, JK_LOG_DEBUG,
- "uriEnv.init() prefix mapping %s=%s\n",
- uriEnv->prefix, uriEnv->workerName);
- }
- }
- } else {
- /* Something like : JkMount /servlets/exampl* ajp13 */
- /* Is this valid ??? */
+ if (uri[strlen(uri) - 1] == '*') {
+ /* context based /context/prefix/ASTERISK */
+ uriEnv->suffix = NULL;
uriEnv->prefix = uri;
uriEnv->prefix_len =strlen( uriEnv->prefix );
- uriEnv->suffix = NULL;
uriEnv->match_type = MATCH_TYPE_PREFIX;
if( uriEnv->mbean->debug > 0 ) {
env->l->jkLog(env, env->l, JK_LOG_DEBUG,
- "uriEnv.init() prefix mapping2 %s=%s\n",
- uri, uriEnv->workerName);
+ "uriEnv.init() prefix mapping %s=%s\n",
+ uriEnv->prefix, uriEnv->workerName);
+ }
+ }
+ else {
+ /*
+ * We have an * or ? in the uri.
+ */
+ uriEnv->suffix = uri;
+ uriEnv->prefix = NULL;
+ uriEnv->suffix_len = strlen(uri);
+ uriEnv->match_type = MATCH_TYPE_SUFFIX;
+ if( uriEnv->mbean->debug > 0 ) {
+ env->l->jkLog(env, env->l, JK_LOG_DEBUG,
+ "uriEnv.init() suffix mapping %s=%s\n",
+ uriEnv->prefix, uriEnv->workerName);
}
}
if( uriEnv->mbean->debug > 0 )
1.65 +19 -35 jakarta-tomcat-connectors/jk/native2/common/jk_uriMap.c
Index: jk_uriMap.c
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_uriMap.c,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -r1.64 -r1.65
--- jk_uriMap.c 18 Apr 2003 08:52:50 -0000 1.64
+++ jk_uriMap.c 21 Apr 2003 08:20:35 -0000 1.65
@@ -85,6 +85,12 @@
static int jk2_uriMap_checkUri(jk_env_t *env, jk_uriMap_t *uriMap,
const char *uri);
+#ifdef WIN32
+static int jk2_uri_icase = 1;
+#else
+static int jk2_uri_icase = 0;
+#endif
+
/*
* We are now in a security nightmare, it maybe that somebody sent
* us a uri that looks like /top-secret.jsp. and the web server will
@@ -264,24 +270,8 @@
for (i = 0; i < sz; i++) {
jk_uriEnv_t *uwr = mapTable->valueAt(env, mapTable, i);
- /* for WinXX, fix the JsP != jsp problems */
-#ifdef WIN32
- if (strcasecmp(suffix, uwr->suffix) == 0) {
-#else
- if (strcmp(suffix, uwr->suffix) == 0) {
-#endif
- if (uriMap->mbean->debug > 0) {
- env->l->jkLog(env, env->l,JK_LOG_DEBUG,
- "uriMap.mapUri() suffix match %s\n",
- uwr->suffix);
- }
- return uwr;
- /* indentation trick */
-#ifdef WIN32
- }
-#else
- }
-#endif
+ if (!jk2_strcmp_match(suffix, uwr->suffix, jk2_uri_icase))
+ return uwr;
}
return NULL;
}
@@ -911,7 +901,6 @@
int longest_match = 0;
char *clean_uri = NULL;
char *url_rewrite = NULL;
- const char *suffix;
int uriLen;
jk_uriEnv_t *hostEnv;
jk_uriEnv_t *ctxEnv;
@@ -1044,22 +1033,17 @@
return match;
}
- /* And extension match at the end */
- /* Only once, no need to compute it for each extension match */
- suffix = jk2_findExtension(env, uri);
- if (suffix != NULL) {
- match = jk2_uriMap_suffixMap(env, uriMap, ctxEnv->suffixMatch,
- suffix, strlen(suffix));
- if (match != NULL) {
- /* restore */
- if (url_rewrite)
- *url_rewrite = origChar;
- if (uriMap->mbean->debug > 0)
- env->l->jkLog(env, env->l, JK_LOG_DEBUG,
- "uriMap.mapUri() extension match %s %s\n",
- uri, match->workerName);
- return match;
- }
+ /* And do a wild char match at the end */
+ match = jk2_uriMap_suffixMap(env, uriMap, ctxEnv->suffixMatch, uri, 0);
+ if (match != NULL) {
+ /* restore */
+ if (url_rewrite)
+ *url_rewrite = origChar;
+ if (uriMap->mbean->debug > 0)
+ env->l->jkLog(env, env->l, JK_LOG_DEBUG,
+ "uriMap.mapUri() extension match %s %s\n",
+ uri, match->workerName);
+ return match;
}
/* restore */
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org