break;
case FR_TYPE_GROUP:
+ {
+ fr_sbuff_escape_rules_t my_e_rules;
+
+ /*
+ * If the caller didn't ask to escape binary data
+ * in 'octets' types, then we force that now.
+ * Otherwise any 'octets' type which is buried
+ * inside of a 'group' will get copied verbatim
+ * from input to output, with no escaping!
+ */
+ if (!e_rules || (!e_rules->do_oct && !e_rules->do_hex)) {
+ e_rules = &fr_value_escape_double;
+ }
+
/*
* Represent groups as:
*
", ", (sizeof(", ") - 1), e_rules,
0, false);
FR_SBUFF_IN_CHAR_RETURN(&our_out, '}');
+ }
break;
case FR_TYPE_NULL:
break;
case FR_TYPE_OCTETS:
- if (vb->tainted && e_rules) goto cast;
-
- slen = fr_sbuff_in_bstrncpy(&our_sbuff, (char const *)vb->vb_strvalue, vb->vb_length);
+ /*
+ * Copy the raw string over, if necessary with escaping.
+ */
+ if (e_rules && (vb->tainted || e_rules->do_oct || e_rules->do_hex)) {
+ slen = fr_sbuff_in_escape(&our_sbuff, (char const *)vb->vb_strvalue, vb->vb_length, e_rules);
+ } else {
+ slen = fr_sbuff_in_bstrncpy(&our_sbuff, (char const *)vb->vb_strvalue, vb->vb_length);
+ }
break;
case FR_TYPE_STRING:
xlat_purify <ipaddr>127.0.0.1 == "127.0.0.1"
match true
-# Invalid cast from octets to ipaddr.
+# LHS is IPaddr, RHS is string.
xlat_purify <ipaddr>127.0.0.1 == "%{md4: 127.0.0.1}"
-match NULL
+match false
#
# Bare %{...} is allowed.
#
+# Invalid cast from octets to ipaddr.
xlat_purify <ipaddr>127.0.0.1 == %{md4:127.0.0.1}
match NULL
match (&User-Name == 0x544924d05ec4481925ba3749a096a0a7)
xlat_purify (&User-Name == "%{md4: blah}")
-match (&User-Name == "TI$\320^\304H\031\%\2727I\240\226\240\247")
+match (&User-Name == "0x544924d05ec4481925ba3749a096a0a7")
+
+# and without the double quotes.
+xlat_purify (&User-Name == %{md4: blah})
+match (&User-Name == 0x544924d05ec4481925ba3749a096a0a7)
xlat_purify <ipaddr>127.0.0.1 == 2130706433
match true
count
-match 312
+match 314