mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-11-12 20:47:06 +00:00
FS-4627 --resolve
This commit is contained in:
1 parent
d80e91d248
commit
016550f218
9 files changed
+252
-166
No files matched your search
@@ -1069,28 +1069,33 @@ MSG_HEADER_CLASS(msg_, accept, "Accept", "", ac_params, apndlist,
|
||||
|
||||
issize_t msg_accept_d(su_home_t *home, msg_header_t *h, char *s, isize_t slen)
|
||||
{
|
||||
msg_accept_t *ac = (msg_accept_t *)h;
|
||||
msg_accept_t *ac;
|
||||
|
||||
while (*s == ',') /* Ignore empty entries (comma-whitespace) */
|
||||
*s = '\0', s += span_lws(s + 1) + 1;
|
||||
for(;;) {
|
||||
ac = (msg_accept_t *)h;
|
||||
|
||||
if (*s == '\0') {
|
||||
/* Empty Accept list is not an error */
|
||||
ac->ac_type = ac->ac_subtype = "";
|
||||
return 0;
|
||||
}
|
||||
while (*s == ',') /* Ignore empty entries (comma-whitespace) */
|
||||
*s = '\0', s += span_lws(s + 1) + 1;
|
||||
|
||||
/* "Accept:" #(type/subtyp ; *(parameters))) */
|
||||
if (msg_mediatype_d(&s, &ac->ac_type) == -1)
|
||||
return -1;
|
||||
if (!(ac->ac_subtype = strchr(ac->ac_type, '/')))
|
||||
return -1;
|
||||
ac->ac_subtype++;
|
||||
if (*s == '\0') {
|
||||
/* Empty Accept list is not an error */
|
||||
ac->ac_type = ac->ac_subtype = "";
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (*s == ';' && msg_params_d(home, &s, &ac->ac_params) == -1)
|
||||
return -1;
|
||||
/* "Accept:" #(type/subtyp ; *(parameters))) */
|
||||
if (msg_mediatype_d(&s, &ac->ac_type) == -1)
|
||||
return -1;
|
||||
if (!(ac->ac_subtype = strchr(ac->ac_type, '/')))
|
||||
return -1;
|
||||
ac->ac_subtype++;
|
||||
|
||||
if (*s == ';' && msg_params_d(home, &s, &ac->ac_params) == -1)
|
||||
return -1;
|
||||
|
||||
msg_parse_next_field_without_recursion();
|
||||
}
|
||||
|
||||
return msg_parse_next_field(home, h, s, slen);
|
||||
}
|
||||
|
||||
issize_t msg_accept_e(char b[], isize_t bsiz, msg_header_t const *h, int flags)
|
||||
@@ -1167,22 +1172,26 @@ issize_t msg_accept_any_d(su_home_t *home,
|
||||
char *s, isize_t slen)
|
||||
{
|
||||
/** @relatesalso msg_accept_any_s */
|
||||
msg_accept_any_t *aa = (msg_accept_any_t *)h;
|
||||
msg_accept_any_t *aa;
|
||||
|
||||
while (*s == ',') /* Ignore empty entries (comma-whitespace) */
|
||||
*s = '\0', s += span_lws(s + 1) + 1;
|
||||
for(;;) {
|
||||
aa = (msg_accept_any_t *)h;
|
||||
while (*s == ',') /* Ignore empty entries (comma-whitespace) */
|
||||
*s = '\0', s += span_lws(s + 1) + 1;
|
||||
|
||||
if (*s == '\0')
|
||||
return -2; /* Empty list */
|
||||
if (*s == '\0')
|
||||
return -2; /* Empty list */
|
||||
|
||||
/* "Accept-*:" 1#(token *(SEMI accept-param)) */
|
||||
if (msg_token_d(&s, &aa->aa_value) == -1)
|
||||
return -1;
|
||||
/* "Accept-*:" 1#(token *(SEMI accept-param)) */
|
||||
if (msg_token_d(&s, &aa->aa_value) == -1)
|
||||
return -1;
|
||||
|
||||
if (*s == ';' && msg_params_d(home, &s, &aa->aa_params) == -1)
|
||||
return -1;
|
||||
if (*s == ';' && msg_params_d(home, &s, &aa->aa_params) == -1)
|
||||
return -1;
|
||||
|
||||
msg_parse_next_field_without_recursion();
|
||||
}
|
||||
|
||||
return msg_parse_next_field(home, h, s, slen);
|
||||
}
|
||||
|
||||
/** Encode an Accept-* header field. */
|
||||
@@ -2071,29 +2080,33 @@ MSG_HEADER_CLASS_G(content_transfer_encoding, "Content-Transfer-Encoding",
|
||||
|
||||
issize_t msg_warning_d(su_home_t *home, msg_header_t *h, char *s, isize_t slen)
|
||||
{
|
||||
msg_warning_t *w = (msg_warning_t *)h;
|
||||
msg_warning_t *w;
|
||||
char *text;
|
||||
|
||||
while (*s == ',') /* Ignore empty entries (comma-whitespace) */
|
||||
*s = '\0', s += span_lws(s + 1) + 1;
|
||||
for(;;) {
|
||||
w = (msg_warning_t *)h;
|
||||
while (*s == ',') /* Ignore empty entries (comma-whitespace) */
|
||||
*s = '\0', s += span_lws(s + 1) + 1;
|
||||
|
||||
/* Parse protocol */
|
||||
if (!IS_DIGIT(*s))
|
||||
return -1;
|
||||
w->w_code = strtoul(s, &s, 10);
|
||||
skip_lws(&s);
|
||||
/* Parse protocol */
|
||||
if (!IS_DIGIT(*s))
|
||||
return -1;
|
||||
w->w_code = strtoul(s, &s, 10);
|
||||
skip_lws(&s);
|
||||
|
||||
/* Host (and port) */
|
||||
if (msg_hostport_d(&s, &w->w_host, &w->w_port) == -1)
|
||||
return -1;
|
||||
if (msg_quoted_d(&s, &text) == -1)
|
||||
return -1;
|
||||
if (msg_unquote(text, text) == NULL)
|
||||
return -1;
|
||||
/* Host (and port) */
|
||||
if (msg_hostport_d(&s, &w->w_host, &w->w_port) == -1)
|
||||
return -1;
|
||||
if (msg_quoted_d(&s, &text) == -1)
|
||||
return -1;
|
||||
if (msg_unquote(text, text) == NULL)
|
||||
return -1;
|
||||
|
||||
w->w_text = text;
|
||||
w->w_text = text;
|
||||
|
||||
msg_parse_next_field_without_recursion();
|
||||
}
|
||||
|
||||
return msg_parse_next_field(home, h, s, slen);
|
||||
}
|
||||
|
||||
issize_t msg_warning_e(char b[], isize_t bsiz, msg_header_t const *h, int f)
|
||||
|
||||
@@ -1190,6 +1190,7 @@ msg_header_t *error_header_parse(msg_t *msg, msg_pub_t *mo,
|
||||
return h;
|
||||
}
|
||||
|
||||
|
||||
/** Complete this header field and parse next header field.
|
||||
*
|
||||
* This function completes parsing a multi-field header like @Accept,
|
||||
@@ -1238,6 +1239,7 @@ issize_t msg_parse_next_field(su_home_t *home, msg_header_t *prev,
|
||||
return hc->hc_parse(home, h, s, end - s);
|
||||
}
|
||||
|
||||
|
||||
/** Decode a message header. */
|
||||
msg_header_t *msg_header_d(su_home_t *home, msg_t const *msg, char const *b)
|
||||
{
|
||||
|
||||
@@ -185,6 +185,34 @@ SOFIAPUBFUN issize_t msg_unquoted_e(char *b, isize_t bsiz, char const *s);
|
||||
SOFIAPUBFUN issize_t msg_parse_next_field(su_home_t *home, msg_header_t *prev,
|
||||
char *s, isize_t slen);
|
||||
|
||||
#define msg_parse_next_field_without_recursion() { \
|
||||
msg_header_t *prev = h; \
|
||||
msg_hclass_t *hc = prev->sh_class; \
|
||||
char *end = s + slen; \
|
||||
\
|
||||
if (*s && *s != ',') \
|
||||
return -1; \
|
||||
\
|
||||
if (msg_header_update_params(prev->sh_common, 0) < 0) \
|
||||
return -1; \
|
||||
\
|
||||
while (*s == ',') \
|
||||
*s = '\0', s += span_lws(s + 1) + 1; \
|
||||
\
|
||||
if (*s == 0) \
|
||||
return 0; \
|
||||
\
|
||||
h = msg_header_alloc(home, hc, 0); \
|
||||
if (!h) \
|
||||
return -1; \
|
||||
\
|
||||
prev->sh_succ = h, h->sh_prev = &prev->sh_succ; \
|
||||
prev->sh_next = h; \
|
||||
slen = end - s; \
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** Terminate encoding. @HI */
|
||||
#define MSG_TERM_E(p, e) ((p) < (e) ? (p)[0] = '\0' : '\0')
|
||||
|
||||
|
||||
Reference in new issue
Block a user