View | Details | Raw Unified | Return to bug 11294
Collapse All | Expand All

(-)httpd-2.0/modules/mappers/mod_vhost_alias.c (-7 / +34 lines)
Lines 64-69 Link Here
64
typedef struct mva_sconf_t {
64
typedef struct mva_sconf_t {
65
    const char *doc_root;
65
    const char *doc_root;
66
    const char *cgi_root;
66
    const char *cgi_root;
67
    const char *unset_part;
68
    int unset_part_len;
67
    mva_mode_e doc_root_mode;
69
    mva_mode_e doc_root_mode;
68
    mva_mode_e cgi_root_mode;
70
    mva_mode_e cgi_root_mode;
69
} mva_sconf_t;
71
} mva_sconf_t;
Lines 75-80 Link Here
75
    conf = (mva_sconf_t *) apr_pcalloc(p, sizeof(mva_sconf_t));
77
    conf = (mva_sconf_t *) apr_pcalloc(p, sizeof(mva_sconf_t));
76
    conf->doc_root = NULL;
78
    conf->doc_root = NULL;
77
    conf->cgi_root = NULL;
79
    conf->cgi_root = NULL;
80
    conf->unset_part = "_";
81
    conf->unset_part_len = 1;
78
    conf->doc_root_mode = VHOST_ALIAS_UNSET;
82
    conf->doc_root_mode = VHOST_ALIAS_UNSET;
79
    conf->cgi_root_mode = VHOST_ALIAS_UNSET;
83
    conf->cgi_root_mode = VHOST_ALIAS_UNSET;
80
    return conf;
84
    return conf;
Lines 103-108 Link Here
103
	conf->cgi_root_mode = child->cgi_root_mode;
107
	conf->cgi_root_mode = child->cgi_root_mode;
104
	conf->cgi_root = child->cgi_root;
108
	conf->cgi_root = child->cgi_root;
105
    }
109
    }
110
    if (strcmp(child->unset_part, "_") != 0) {
111
        conf->unset_part = child->unset_part;
112
        conf->unset_part_len = child->unset_part_len;
113
    }
114
    else {
115
        conf->unset_part = parent->unset_part;
116
        conf->unset_part_len = parent->unset_part_len;
117
    }
106
    return conf;
118
    return conf;
107
}
119
}
108
120
Lines 211-216 Link Here
211
    return NULL;
223
    return NULL;
212
}
224
}
213
225
226
static const char *vhost_alias_set_part(cmd_parms *cmd, void *dummy,
227
					const char *unset_part)
228
{
229
    mva_sconf_t *conf;
230
    conf = (mva_sconf_t *) ap_get_module_config(cmd->server->module_config,
231
						&vhost_alias_module);
232
    conf->unset_part = unset_part;
233
    conf->unset_part_len = strlen(unset_part);
234
    return NULL;
235
}
236
214
static const command_rec mva_commands[] =
237
static const command_rec mva_commands[] =
215
{
238
{
216
    AP_INIT_TAKE1("VirtualScriptAlias", vhost_alias_set, 
239
    AP_INIT_TAKE1("VirtualScriptAlias", vhost_alias_set, 
Lines 225-230 Link Here
225
    AP_INIT_TAKE1("VirtualDocumentRootIP", vhost_alias_set, 
248
    AP_INIT_TAKE1("VirtualDocumentRootIP", vhost_alias_set, 
226
                  &vhost_alias_set_doc_root_ip, RSRC_CONF, 
249
                  &vhost_alias_set_doc_root_ip, RSRC_CONF, 
227
                  "how to create the DocumentRoot based on the host"),
250
                  "how to create the DocumentRoot based on the host"),
251
    AP_INIT_TAKE1("VirtualUnsetPart", vhost_alias_set_part,
252
                  NULL, RSRC_CONF,
253
                  "how to set the replacement for empty parts"),
228
    { NULL }
254
    { NULL }
229
};
255
};
230
256
Lines 249-256 Link Here
249
    }
275
    }
250
}
276
}
251
277
252
static void vhost_alias_interpolate(request_rec *r, const char *name,
278
static void vhost_alias_interpolate(request_rec *r, mva_sconf_t *conf,
253
				    const char *map, const char *uri)
279
				    const char *name, const char *map,
280
				    const char *uri)
254
{
281
{
255
    /* 0..9 9..0 */
282
    /* 0..9 9..0 */
256
    enum { MAXDOTS = 19 };
283
    enum { MAXDOTS = 19 };
Lines 326-333 Link Here
326
	end = dots[ndots]; /* ptr to the character after the last one */
353
	end = dots[ndots]; /* ptr to the character after the last one */
327
	if (N != 0) {
354
	if (N != 0) {
328
	    if (N > ndots) {
355
	    if (N > ndots) {
329
		start = "_";
356
		start = conf->unset_part;
330
		end = start+1;
357
		end = start+conf->unset_part_len;
331
	    }
358
	    }
332
	    else if (!Nd) {
359
	    else if (!Nd) {
333
		start = dots[N-1]+1;
360
		start = dots[N-1]+1;
Lines 344-351 Link Here
344
	}
371
	}
345
	if (M != 0) {
372
	if (M != 0) {
346
	    if (M > end - start) {
373
	    if (M > end - start) {
347
		start = "_";
374
		start = conf->unset_part;
348
		end = start+1;
375
		end = start+conf->unset_part_len;
349
	    }
376
	    }
350
	    else if (!Md) {
377
	    else if (!Md) {
351
		start = start+M-1;
378
		start = start+M-1;
Lines 425-431 Link Here
425
     * canonical_path buffer.
452
     * canonical_path buffer.
426
     */
453
     */
427
    r->canonical_filename = "";
454
    r->canonical_filename = "";
428
    vhost_alias_interpolate(r, name, map, uri);
455
    vhost_alias_interpolate(r, conf, name, map, uri);
429
456
430
    if (cgi) {
457
    if (cgi) {
431
	/* see is_scriptaliased() in mod_cgi */
458
	/* see is_scriptaliased() in mod_cgi */

Return to bug 11294