From 282e2c0a167cea65e0e4ca89b29db5fa2fa0d178 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Wed, 10 Jan 2024 16:35:57 -0500 Subject: [PATCH] MT#55283 extend attribute pattern matching For attributes that have a value, consider both the full attribute string `a=name:value` and just the attribute name itself `a=name` when checking for removal and substitution instructions. Change-Id: Ia648a4db8c80a5c23abf44f75b45e29acdf1b91d --- daemon/sdp.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/daemon/sdp.c b/daemon/sdp.c index 9f2931f16..45d66b9cc 100644 --- a/daemon/sdp.c +++ b/daemon/sdp.c @@ -2939,6 +2939,8 @@ static void generic_append_attr_to_gstring(GString *s, const char * name, char s if (attr_subst) g_string_append_len(s, attr_subst->s, attr_subst->len); // complete attribute else { + gsize attr_start = s->len; // save beginning of complete attribute string + /* attr name */ g_string_append_len(s, attr.s, attr.len); @@ -2946,6 +2948,23 @@ static void generic_append_attr_to_gstring(GString *s, const char * name, char s if (value && value->len) { g_string_append_c(s, separator); g_string_append_len(s, value->s, value->len); + + // check if the complete attribute string is marked for removal ... + str complete = STR_INIT_LEN(s->str + attr_start, s->len - attr_start); + if (sdp_manipulate_remove(sdp_manipulations, &complete)) + { + // rewind and bail + g_string_truncate(s, attr_start - 2); // -2 for `a=` + return; + } + + // ... or substitution + attr_subst = sdp_manipulations_subst(sdp_manipulations, &complete); + if (attr_subst) { + // rewind and replace + g_string_truncate(s, attr_start); + g_string_append_len(s, attr_subst->s, attr_subst->len); + } } }