From: Arran Cudbard-Bell Date: Tue, 23 Jan 2024 00:18:49 +0000 (-0600) Subject: Don't apply body restrictions to xlat calls X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a1bf68d46fdce8a328d5166cc09526f321a73a86;p=thirdparty%2Ffreeradius-server.git Don't apply body restrictions to xlat calls --- diff --git a/src/modules/rlm_rest/rlm_rest.c b/src/modules/rlm_rest/rlm_rest.c index 1b2640b19b7..8d7aeccddd4 100644 --- a/src/modules/rlm_rest/rlm_rest.c +++ b/src/modules/rlm_rest/rlm_rest.c @@ -1107,7 +1107,7 @@ static int parse_sub_section(rlm_rest_t *inst, CONF_SECTION *parent, conf_parser * figure out what content-type to use. So if they've used the canonical form we * need to convert it back into a proper HTTP content_type value. */ - if ((request_cs = cf_section_find(cs, "request", NULL)) && cf_pair_find(request_cs, "data")) { + if ((strcmp(name, "xlat") == 0) || ((request_cs = cf_section_find(cs, "request", NULL)) && cf_pair_find(request_cs, "data"))) { http_body_type_t body; config->request.body = REST_HTTP_BODY_CUSTOM; diff --git a/src/tests/modules/rest/module.conf b/src/tests/modules/rest/module.conf index c3a49382153..0813cf9d010 100644 --- a/src/tests/modules/rest/module.conf +++ b/src/tests/modules/rest/module.conf @@ -25,6 +25,7 @@ rest { request { header = 'X-Custom-Header: test' header = "X-Custom-Header: %{User-Name}" + body = 'json' } tls = ${..tls} } diff --git a/src/tests/modules/rest/rest_xlat.unlang b/src/tests/modules/rest/rest_xlat.unlang index ffe7891fc2c..360583c1219 100644 --- a/src/tests/modules/rest/rest_xlat.unlang +++ b/src/tests/modules/rest/rest_xlat.unlang @@ -179,6 +179,11 @@ group { if (!(&headers =~ /"x-freeradius-server":"default"/)) { test_fail } + + # Some weird escaping issue prevents matching application/json + if (!(&headers =~ /"content-type":"application.+json"/)) { + test_fail + } } # Zero length tainted value - check escaping doesn't break on zero length string