Skip to content

Commit

Permalink
don't escape attribute values if we were passed an escape function
Browse files Browse the repository at this point in the history
  • Loading branch information
arr2036 committed Nov 20, 2014
1 parent 7e17e9c commit 2266c65
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/main/xlat.c
Original file line number Diff line number Diff line change
Expand Up @@ -1460,14 +1460,17 @@ 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;
DICT_VALUE *dv;
char *ret = NULL;
int err;

char quote = escape ? '"' : '\0';

vp_cursor_t cursor;

/*
Expand Down Expand Up @@ -1683,11 +1686,11 @@ static char *xlat_getvp(TALLOC_CTX *ctx, REQUEST *request, value_pair_tmpl_t con
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);
Expand All @@ -1711,7 +1714,7 @@ static char *xlat_getvp(TALLOC_CTX *ctx, REQUEST *request, value_pair_tmpl_t con
}

print:
ret = vp_aprints_value(ctx, vp, '"');
ret = vp_aprints_value(ctx, vp, quote);

finish:
talloc_free(virtual);
Expand Down Expand Up @@ -1849,7 +1852,7 @@ static char *xlat_aprint(TALLOC_CTX *ctx, REQUEST *request, xlat_exp_t const * c
/*
* Some attributes are virtual <sigh>
*/
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);
Expand Down

0 comments on commit 2266c65

Please sign in to comment.