Browse Source

mod_ssi printenv: print cgi env, add environment vars to cgi env (fixes #1713)

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@2485 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.4.23
Stefan Bühler 13 years ago
parent
commit
4de9dc077a
  1. 1
      NEWS
  2. 43
      src/mod_ssi.c

1
NEWS

@ -33,6 +33,7 @@ NEWS
* Make mod_extforward headers configurable (fixes #1545)
* Add '%_' pattern for complete hostname in mod_evhost (fixes #1737)
* Add IPv6 support to mod_proxy (fixes #1537)
* mod_ssi printenv: print cgi env, add environment vars to cgi env (fixes #1713)
- 1.4.22 - 2009-03-07
* Fix wrong lua type for CACHE_MISS/CACHE_HIT in mod_cml (fixes #533)

43
src/mod_ssi.c

@ -200,6 +200,34 @@ static int ssi_env_add_request_headers(server *srv, connection *con, plugin_data
}
}
for (i = 0; i < con->environment->used; i++) {
data_string *ds;
ds = (data_string *)con->environment->data[i];
if (ds->value->used && ds->key->used) {
size_t j;
buffer_reset(srv->tmp_buf);
buffer_prepare_append(srv->tmp_buf, ds->key->used + 2);
for (j = 0; j < ds->key->used - 1; j++) {
char c = '_';
if (light_isalpha(ds->key->ptr[j])) {
/* upper-case */
c = ds->key->ptr[j] & ~32;
} else if (light_isdigit(ds->key->ptr[j])) {
/* copy */
c = ds->key->ptr[j];
}
srv->tmp_buf->ptr[srv->tmp_buf->used++] = c;
}
srv->tmp_buf->ptr[srv->tmp_buf->used] = '\0';
ssi_env_add(p->ssi_cgi_env, srv->tmp_buf->ptr, ds->value->ptr);
}
}
return 0;
}
@ -657,17 +685,22 @@ static int process_ssi_stmt(server *srv, connection *con, plugin_data *p,
if (p->if_is_false) break;
b = chunkqueue_get_append_buffer(con->write_queue);
buffer_copy_string_len(b, CONST_STR_LEN("<pre>"));
for (i = 0; i < p->ssi_vars->used; i++) {
data_string *ds = (data_string *)p->ssi_vars->data[p->ssi_vars->sorted[i]];
buffer_append_string_buffer(b, ds->key);
buffer_append_string_len(b, CONST_STR_LEN(": "));
buffer_append_string_buffer(b, ds->value);
buffer_append_string_len(b, CONST_STR_LEN("<br />"));
buffer_append_string_len(b, CONST_STR_LEN("="));
buffer_append_string_encoded(b, CONST_BUF_LEN(ds->value), ENCODING_MINIMAL_XML);
buffer_append_string_len(b, CONST_STR_LEN("\n"));
}
for (i = 0; i < p->ssi_cgi_env->used; i++) {
data_string *ds = (data_string *)p->ssi_cgi_env->data[p->ssi_cgi_env->sorted[i]];
buffer_append_string_buffer(b, ds->key);
buffer_append_string_len(b, CONST_STR_LEN("="));
buffer_append_string_encoded(b, CONST_BUF_LEN(ds->value), ENCODING_MINIMAL_XML);
buffer_append_string_len(b, CONST_STR_LEN("\n"));
}
buffer_append_string_len(b, CONST_STR_LEN("</pre>"));
break;
case SSI_EXEC: {

Loading…
Cancel
Save