From 2266c651a1d46af80e43d8f1311f01d6c36f29ff Mon Sep 17 00:00:00 2001 From: Arran Cudbard-Bell Date: Wed, 19 Nov 2014 23:15:48 -0500 Subject: [PATCH] don't escape attribute values if we were passed an escape function --- src/main/xlat.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/xlat.c b/src/main/xlat.c index d8dfd41..70d3891 100644 --- a/src/main/xlat.c +++ b/src/main/xlat.c @@ -1460,7 +1460,8 @@ static ssize_t xlat_tokenize_request(REQUEST *request, char const *fmt, xlat_exp } -static char *xlat_getvp(TALLOC_CTX *ctx, REQUEST *request, value_pair_tmpl_t const *vpt, bool return_null) +static char *xlat_getvp(TALLOC_CTX *ctx, REQUEST *request, value_pair_tmpl_t const *vpt, + bool escape, bool return_null) { VALUE_PAIR *vp = NULL, *virtual = NULL; RADIUS_PACKET *packet = NULL; @@ -1468,6 +1469,8 @@ static char *xlat_getvp(TALLOC_CTX *ctx, REQUEST *request, value_pair_tmpl_t con char *ret = NULL; int err; + char quote = escape ? '"' : '\0'; + vp_cursor_t cursor; /* @@ -1683,11 +1686,11 @@ do_print: char *p, *q; if (!fr_cursor_current(&cursor)) return NULL; - p = vp_aprints_value(ctx, vp, '"'); + p = vp_aprints_value(ctx, vp, quote); if (!p) return NULL; while ((vp = tmpl_cursor_next(&cursor, vpt)) != NULL) { - q = vp_aprints_value(ctx, vp, '"'); + q = vp_aprints_value(ctx, vp, quote); if (!q) return NULL; p = talloc_strdup_append(p, ","); p = talloc_strdup_append(p, q); @@ -1711,7 +1714,7 @@ do_print: } print: - ret = vp_aprints_value(ctx, vp, '"'); + ret = vp_aprints_value(ctx, vp, quote); finish: talloc_free(virtual); @@ -1849,7 +1852,7 @@ static char *xlat_aprint(TALLOC_CTX *ctx, REQUEST *request, xlat_exp_t const * c /* * Some attributes are virtual */ - str = xlat_getvp(ctx, request, &node->attr, true); + str = xlat_getvp(ctx, request, &node->attr, escape ? false : true, true); if (str) { XLAT_DEBUG("EXPAND attr %s", node->attr.tmpl_da->name); XLAT_DEBUG(" ---> %s", str); -- 2.1.4