Author: covener
Date: Mon Jun 1 17:41:30 2026
New Revision: 1934852
Log:
expr parse fail should hide conditional content
these are neither true or false, the enclosing content should not
be printed
Added:
httpd/httpd/trunk/changes-entries/includes-error.txt
Modified:
httpd/httpd/trunk/modules/filters/mod_include.c
httpd/httpd/trunk/modules/filters/mod_include.h
Added: httpd/httpd/trunk/changes-entries/includes-error.txt
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ httpd/httpd/trunk/changes-entries/includes-error.txt Mon Jun 1 17:41:30 2026 (r1934852)
@@ -0,0 +1,2 @@
+ *) mod_include: Don't print any of if/elsif/else content when
+ a conditional evaluation returns an error. [Eric Covener]
Modified: httpd/httpd/trunk/modules/filters/mod_include.c
==============================================================================
--- httpd/httpd/trunk/modules/filters/mod_include.c Mon Jun 1 17:11:37 2026 (r1934851)
+++ httpd/httpd/trunk/modules/filters/mod_include.c Mon Jun 1 17:41:30 2026 (r1934852)
@@ -2329,6 +2329,8 @@ static apr_status_t handle_if(include_ct
if (ctx->argc != 1) {
SSI_CREATE_ERROR_BUCKET(ctx, f, bb);
+ ctx->flags &= SSI_FLAG_CLEAR_PRINT_COND;
+ ctx->flags |= SSI_FLAG_COND_ERROR;
return APR_SUCCESS;
}
@@ -2338,6 +2340,8 @@ static apr_status_t handle_if(include_ct
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01354) "unknown parameter \"%s\" "
"to tag if in %s", tag, r->filename);
SSI_CREATE_ERROR_BUCKET(ctx, f, bb);
+ ctx->flags &= SSI_FLAG_CLEAR_PRINT_COND;
+ ctx->flags |= SSI_FLAG_COND_ERROR;
return APR_SUCCESS;
}
@@ -2345,6 +2349,8 @@ static apr_status_t handle_if(include_ct
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01355) "missing expr value for if "
"element in %s", r->filename);
SSI_CREATE_ERROR_BUCKET(ctx, f, bb);
+ ctx->flags &= SSI_FLAG_CLEAR_PRINT_COND;
+ ctx->flags |= SSI_FLAG_COND_ERROR;
return APR_SUCCESS;
}
@@ -2356,6 +2362,8 @@ static apr_status_t handle_if(include_ct
expr_ret = parse_ap_expr(ctx, expr, &was_error);
if (was_error) {
+ ctx->flags &= SSI_FLAG_CLEAR_PRINT_COND;
+ ctx->flags |= SSI_FLAG_COND_ERROR;
SSI_CREATE_ERROR_BUCKET(ctx, f, bb);
return APR_SUCCESS;
}
@@ -2401,6 +2409,8 @@ static apr_status_t handle_elif(include_
if (ctx->argc != 1) {
SSI_CREATE_ERROR_BUCKET(ctx, f, bb);
+ ctx->flags &= SSI_FLAG_CLEAR_PRINT_COND;
+ ctx->flags |= SSI_FLAG_COND_ERROR;
return APR_SUCCESS;
}
@@ -2410,6 +2420,8 @@ static apr_status_t handle_elif(include_
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01358) "unknown parameter \"%s\" "
"to tag if in %s", tag, r->filename);
SSI_CREATE_ERROR_BUCKET(ctx, f, bb);
+ ctx->flags &= SSI_FLAG_CLEAR_PRINT_COND;
+ ctx->flags |= SSI_FLAG_COND_ERROR;
return APR_SUCCESS;
}
@@ -2417,6 +2429,8 @@ static apr_status_t handle_elif(include_
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01359) "missing expr in elif "
"statement: %s", r->filename);
SSI_CREATE_ERROR_BUCKET(ctx, f, bb);
+ ctx->flags &= SSI_FLAG_CLEAR_PRINT_COND;
+ ctx->flags |= SSI_FLAG_COND_ERROR;
return APR_SUCCESS;
}
@@ -2434,6 +2448,8 @@ static apr_status_t handle_elif(include_
expr_ret = parse_ap_expr(ctx, expr, &was_error);
if (was_error) {
+ ctx->flags &= SSI_FLAG_CLEAR_PRINT_COND;
+ ctx->flags |= SSI_FLAG_COND_ERROR;
SSI_CREATE_ERROR_BUCKET(ctx, f, bb);
return APR_SUCCESS;
}
@@ -2480,6 +2496,11 @@ static apr_status_t handle_else(include_
DEBUG_DUMP_COND(ctx, " else");
+ /* Don't toggle printing if there was an expression evaluation error */
+ if (ctx->flags & SSI_FLAG_COND_ERROR) {
+ return APR_SUCCESS;
+ }
+
if (ctx->flags & SSI_FLAG_COND_TRUE) {
ctx->flags &= SSI_FLAG_CLEAR_PRINTING;
}
@@ -2519,6 +2540,7 @@ static apr_status_t handle_endif(include
DEBUG_DUMP_COND(ctx, "endif");
ctx->flags |= (SSI_FLAG_PRINTING | SSI_FLAG_COND_TRUE);
+ ctx->flags &= ~SSI_FLAG_COND_ERROR;
return APR_SUCCESS;
}
Modified: httpd/httpd/trunk/modules/filters/mod_include.h
==============================================================================
--- httpd/httpd/trunk/modules/filters/mod_include.h Mon Jun 1 17:11:37 2026 (r1934851)
+++ httpd/httpd/trunk/modules/filters/mod_include.h Mon Jun 1 17:41:30 2026 (r1934852)
@@ -57,6 +57,7 @@
#define SSI_FLAG_COND_TRUE (1<<1) /* Conditional eval'd to true. */
#define SSI_FLAG_SIZE_IN_BYTES (1<<2) /* Sizes displayed in bytes. */
#define SSI_FLAG_NO_EXEC (1<<3) /* No Exec in current context. */
+#define SSI_FLAG_COND_ERROR (1<<4) /* Conditional evaluation was in error */
#define SSI_FLAG_SIZE_ABBREV (~(SSI_FLAG_SIZE_IN_BYTES))
#define SSI_FLAG_CLEAR_PRINT_COND (~((SSI_FLAG_PRINTING) | \
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.