diff options
Diffstat (limited to 'src/mod_cgi.c')
-rw-r--r-- | src/mod_cgi.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/mod_cgi.c b/src/mod_cgi.c index 083be91..c50bfd1 100644 --- a/src/mod_cgi.c +++ b/src/mod_cgi.c @@ -811,8 +811,14 @@ static int cgi_create_env(server *srv, connection *con, plugin_data *p, buffer * if (!buffer_is_empty(con->server_name)) { size_t len = con->server_name->used - 1; - char *colon = strchr(con->server_name->ptr, ':'); - if (colon) len = colon - con->server_name->ptr; + + if (con->server_name->ptr[0] == '[') { + const char *colon = strstr(con->server_name->ptr, "]:"); + if (colon) len = (colon + 1) - con->server_name->ptr; + } else { + const char *colon = strchr(con->server_name->ptr, ':'); + if (colon) len = colon - con->server_name->ptr; + } cgi_env_add(&env, CONST_STR_LEN("SERVER_NAME"), con->server_name->ptr, len); } else { |