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

(-)mod_include.c.orig (-7 / +99 lines)
Lines 806-812 Link Here
806
    return 0;
806
    return 0;
807
}
807
}
808
808
809
810
static int handle_echo(include_ctx_t *ctx, apr_bucket_brigade **bb, 
809
static int handle_echo(include_ctx_t *ctx, apr_bucket_brigade **bb, 
811
                       request_rec *r, ap_filter_t *f, apr_bucket *head_ptr, 
810
                       request_rec *r, ap_filter_t *f, apr_bucket *head_ptr, 
812
                       apr_bucket **inserted_head)
811
                       apr_bucket **inserted_head)
Lines 868-879 Link Here
868
                    *inserted_head = tmp_buck;
867
                    *inserted_head = tmp_buck;
869
                }
868
                }
870
            }
869
            }
871
            else if (!strcmp(tag, "text")) {
870
			else if (!strcmp(tag, "text")) { // added by djm
872
                APR_BUCKET_INSERT_BEFORE(head_ptr, tmp_buck);
871
				conn_rec *c = r->connection;
872
                e_len = strlen(tag_val);
873
                tmp_buck = apr_bucket_pool_create(tag_val, e_len,
874
                                                      r->pool, c->bucket_alloc);
875
 				APR_BUCKET_INSERT_BEFORE(head_ptr, tmp_buck);
873
                if (*inserted_head == NULL) {
876
                if (*inserted_head == NULL) {
874
                    *inserted_head = tmp_buck;
877
                    *inserted_head = tmp_buck;
875
                }
878
                }
876
            }
879
 			}
877
            else if (!strcmp(tag, "encoding")) {
880
            else if (!strcmp(tag, "encoding")) {
878
                if (!strcasecmp(tag_val, "none")) encode = E_NONE;
881
                if (!strcasecmp(tag_val, "none")) encode = E_NONE;
879
                else if (!strcasecmp(tag_val, "url")) encode = E_URL;
882
                else if (!strcasecmp(tag_val, "url")) encode = E_URL;
Lines 904-910 Link Here
904
                       request_rec *r, ap_filter_t *f, apr_bucket *head_ptr, 
907
                       request_rec *r, ap_filter_t *f, apr_bucket *head_ptr, 
905
                       apr_bucket **inserted_head)
908
                       apr_bucket **inserted_head)
906
{
909
{
907
    /* Do nothng and do it well */
910
	// Do nothing and do it well
911
	return 0;
912
}
913
914
// Basically the same as handle_echo() except output goes to the log
915
static int handle_log(include_ctx_t *ctx, apr_bucket_brigade **bb, 
916
                       request_rec *r, ap_filter_t *f, apr_bucket *head_ptr, 
917
                       apr_bucket **inserted_head)
918
{
919
    char       *tag       = NULL;
920
    char       *tag_val   = NULL;
921
    const char *log_text = NULL;
922
    apr_bucket  *tmp_buck;
923
    apr_size_t l_len;
924
    enum {E_NONE, E_URL, E_ENTITY} encode;
925
926
    encode = E_ENTITY;
927
928
    *inserted_head = NULL;
929
    if (ctx->flags & FLAG_PRINTING) {
930
        while (1) {
931
            ap_ssi_get_tag_and_value(ctx, &tag, &tag_val, 1);
932
            if (tag_val == NULL) {
933
                if (tag != NULL) {
934
                    return 1;
935
                }
936
                else {
937
                    return 0;
938
                }
939
            }
940
            if (!strcmp(tag, "var")) {
941
                conn_rec *c = r->connection;
942
                const char *val =
943
                    get_include_var(r, ctx,
944
                                    ap_ssi_parse_string(r, ctx, tag_val, NULL,
945
                                                        MAX_STRING_LEN, 0));
946
                if (val) {
947
                    switch(encode) {
948
                    case E_NONE:   
949
                        log_text = val;
950
                        break;
951
                    case E_URL:
952
                        log_text = ap_escape_uri(r->pool, val);  
953
                        break;
954
                    case E_ENTITY: 
955
                        log_text = ap_escape_html(r->pool, val); 
956
                        break;
957
                    }
958
959
                    l_len = strlen(log_text);
960
                    tmp_buck = apr_bucket_pool_create(log_text, l_len,
961
                                                      r->pool, c->bucket_alloc);
962
                }
963
                else {
964
                    include_server_config *sconf= 
965
                        ap_get_module_config(r->server->module_config,
966
                                             &include_module);
967
                    tmp_buck = apr_bucket_pool_create(sconf->undefinedEcho, 
968
                                                      sconf->undefinedEchoLen,
969
                                                      r->pool, c->bucket_alloc);
970
                }
971
				ap_log_rerror(APLOG_MARK, APLOG_NOTICE, 0, r, log_text);
972
            }
973
			else if (!strcmp(tag, "text")) {
974
				ap_log_rerror(APLOG_MARK, APLOG_NOTICE, 0, r, tag_val);
975
			}
976
            else if (!strcmp(tag, "encoding")) {
977
                if (!strcasecmp(tag_val, "none")) encode = E_NONE;
978
                else if (!strcasecmp(tag_val, "url")) encode = E_URL;
979
                else if (!strcasecmp(tag_val, "entity")) encode = E_ENTITY;
980
                else {
981
                    ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
982
                           "unknown value \"%s\" to parameter \"encoding\" of "
983
                           "tag log in %s", tag_val, r->filename);
984
                    CREATE_ERROR_BUCKET(ctx, tmp_buck, head_ptr, 
985
                                        *inserted_head);
986
                    return 1;
987
                }
988
            }
989
            else {
990
                ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
991
                            "unknown parameter \"%s\" in tag log of %s",
992
                            tag, r->filename);
993
                CREATE_ERROR_BUCKET(ctx, tmp_buck, head_ptr, *inserted_head);
994
                return 1;
995
            }
996
997
        }
998
    }
908
    return 0;
999
    return 0;
909
}
1000
}
910
1001
Lines 3629-3636 Link Here
3629
        ssi_pfn_register("include", handle_include);
3720
        ssi_pfn_register("include", handle_include);
3630
        ssi_pfn_register("flastmod", handle_flastmod);
3721
        ssi_pfn_register("flastmod", handle_flastmod);
3631
        ssi_pfn_register("printenv", handle_printenv);
3722
        ssi_pfn_register("printenv", handle_printenv);
3632
        ssi_pfn_register("", handle_comment);
3723
        ssi_pfn_register("comment", handle_comment); // djm
3633
    }
3724
        ssi_pfn_register("log", handle_log); // djm
3725
	}
3634
    return OK;
3726
    return OK;
3635
}
3727
}
3636
3728

Return to bug 34375