[mod_ssi] enhance support for ssi vars

Try ssi_vars if ssi_cgi_env does not have a matching var name.
Allow var names to also include digits after the initial letter or underscore.

From: fbrosson <fbrosson@users.noreply.github.com>

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@3069 152afb58-edef-0310-8abb-c4023f1b3aa9
This commit is contained in:
fbrosson 2016-01-03 14:48:07 +00:00 committed by Stefan Bühler
parent 3dd2f66d13
commit d8e028e069
3 changed files with 7 additions and 3 deletions

1
NEWS
View File

@ -4,6 +4,7 @@ NEWS
====
- 1.4.40
* [mod_ssi] enhance support for ssi vars (thx fbrosson)
- 1.4.39 - 2016-01-02
* [core] fix memset_s call (fixes #2698)

View File

@ -457,9 +457,10 @@ static int process_ssi_stmt(server *srv, connection *con, plugin_data *p, const
}
default: {
data_string *ds;
/* check if it is a cgi-var */
/* check if it is a cgi-var or a ssi-var */
if (NULL != (ds = (data_string *)array_get_element(p->ssi_cgi_env, var_val))) {
if (NULL != (ds = (data_string *)array_get_element(p->ssi_cgi_env, var_val)) ||
NULL != (ds = (data_string *)array_get_element(p->ssi_vars, var_val))) {
chunkqueue_append_mem(con->write_queue, CONST_BUF_LEN(ds->value));
} else {
chunkqueue_append_mem(con->write_queue, CONST_STR_LEN("(none)"));

View File

@ -207,7 +207,9 @@ static int ssi_expr_tokenizer(server *srv, connection *con, plugin_data *p,
buffer_copy_string_len(token, t->input + t->offset + 2, i-3);
} else {
for (i = 1; isalpha(t->input[t->offset + i]) || t->input[t->offset + i] == '_'; i++);
for (i = 1; isalpha(t->input[t->offset + i]) ||
t->input[t->offset + i] == '_' ||
((i > 1) && isdigit(t->input[t->offset + i])); i++);
buffer_copy_string_len(token, t->input + t->offset + 1, i-1);
}