From: Alan T. DeKok Date: Fri, 22 Nov 2024 19:13:43 +0000 (-0500) Subject: add terminals and parse rules for triple-quoted strings X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eaf85dcc54343b8c680f8a276f8ef08e3ec259bd;p=thirdparty%2Ffreeradius-server.git add terminals and parse rules for triple-quoted strings --- diff --git a/src/lib/util/value.c b/src/lib/util/value.c index b586bf3c696..08af6a1f810 100644 --- a/src/lib/util/value.c +++ b/src/lib/util/value.c @@ -568,6 +568,33 @@ fr_sbuff_parse_rules_t const value_parse_rules_backtick_quoted = { L(""), L("\n"), L("\r"), L("`")) }; +/* + * And triple-quoted versions of the above. + */ +fr_sbuff_parse_rules_t const value_parse_rules_double_3quoted = { + .escapes = &fr_value_unescape_double, + .terminals = &FR_SBUFF_TERMS( + L(""), L("\n"), L("\r"), L("\"\"\"")) +}; + +fr_sbuff_parse_rules_t const value_parse_rules_single_3quoted = { + .escapes = &fr_value_unescape_single, + .terminals = &FR_SBUFF_TERMS( + L(""), L("\n"), L("\r"), L("'''")) +}; + +fr_sbuff_parse_rules_t const value_parse_rules_solidus_3quoted = { + .escapes = &fr_value_unescape_solidus, + .terminals = &FR_SBUFF_TERMS( + L(""), L("\n"), L("\r"), L("///")) +}; + +fr_sbuff_parse_rules_t const value_parse_rules_backtick_3quoted = { + .escapes = &fr_value_unescape_backtick, + .terminals = &FR_SBUFF_TERMS( + L(""), L("\n"), L("\r"), L("```")) +}; + /** Parse rules for quoted strings * * These parse rules should be used for internal parsing functions that @@ -591,6 +618,15 @@ fr_sbuff_parse_rules_t const *value_parse_rules_quoted_char[UINT8_MAX] = { ['/'] = &value_parse_rules_solidus_quoted, ['`'] = &value_parse_rules_backtick_quoted }; + +fr_sbuff_parse_rules_t const *value_parse_rules_3quoted[T_TOKEN_LAST] = { + [T_BARE_WORD] = &value_parse_rules_bareword_quoted, + [T_DOUBLE_QUOTED_STRING] = &value_parse_rules_double_3quoted, + [T_SINGLE_QUOTED_STRING] = &value_parse_rules_single_3quoted, + [T_SOLIDUS_QUOTED_STRING] = &value_parse_rules_solidus_3quoted, + [T_BACK_QUOTED_STRING] = &value_parse_rules_backtick_3quoted +}; + /* clang-format on */ /** @} */ diff --git a/src/lib/util/value.h b/src/lib/util/value.h index 63098a8fae4..208084ca8f3 100644 --- a/src/lib/util/value.h +++ b/src/lib/util/value.h @@ -466,6 +466,12 @@ extern fr_sbuff_parse_rules_t const value_parse_rules_solidus_quoted; extern fr_sbuff_parse_rules_t const value_parse_rules_backtick_quoted; extern fr_sbuff_parse_rules_t const *value_parse_rules_quoted[T_TOKEN_LAST]; extern fr_sbuff_parse_rules_t const *value_parse_rules_quoted_char[UINT8_MAX]; + +extern fr_sbuff_parse_rules_t const value_parse_rules_double_3quoted; +extern fr_sbuff_parse_rules_t const value_parse_rules_single_3quoted; +extern fr_sbuff_parse_rules_t const value_parse_rules_solidus_3quoted; +extern fr_sbuff_parse_rules_t const value_parse_rules_backtick_3quoted; +extern fr_sbuff_parse_rules_t const *value_parse_rules_3quoted[T_TOKEN_LAST]; /** @} */ /** @name Allocation and initialisation functions