Skip to content

Commit ad308a4

Browse files
committed
re-enable alternation test
so it now complains about old-style alternations. Mostly. If the complaints cause problems, this commit can be reverted. And then the ":-" text will just get parsed as a static string.
1 parent 90d046d commit ad308a4

3 files changed

Lines changed: 12 additions & 3 deletions

File tree

src/lib/unlang/xlat_tokenize.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@ static fr_sbuff_escape_rules_t const xlat_escape = {
9696

9797
/** Parse rules for literal values inside of an expansion
9898
*
99-
* These rules are used to parse literals as arguments to functions and
100-
* on the RHS of alternations.
99+
* These rules are used to parse literals as arguments to functions.
101100
*
102101
* The caller sets the literal parse rules for outside of expansions when they
103102
* call xlat_tokenize.
@@ -836,7 +835,14 @@ static CC_HINT(nonnull(1,2,4)) ssize_t xlat_tokenize_input(xlat_exp_head_t *head
836835
*/
837836
if (fr_sbuff_adv_past_str_literal(&our_in, "%{")) {
838837
TALLOC_FREE(node); /* nope, couldn't use it */
838+
839839
if (xlat_tokenize_expansion(head, &our_in, t_rules) < 0) goto error;
840+
841+
if (fr_sbuff_is_str_literal(&our_in, ":-")) {
842+
fr_strerror_const("Old style alternation of %{...:-...} is no longer supported");
843+
goto error;
844+
}
845+
840846
next:
841847
fr_sbuff_marker_release(&m_s);
842848
continue;
File renamed without changes.

src/tests/unit/xlat/alternation.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,8 @@ match ERROR offset 23: Missing closing brace
5454
xlat %{%{User-Name}:}
5555
match %{%{User-Name}:}
5656

57+
xlat %{%{User-Name}:-"foo"}
58+
match ERROR offset 15: Old style alternation of %{...:-...} is no longer supported
59+
5760
count
58-
match 33
61+
match 35

0 commit comments

Comments
 (0)