MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / db_url_escape

Function db_url_escape

ut.c:740–780  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

738}
739
740char *db_url_escape(const str *url)
741{
742 static str buf;
743 char *at, *slash, *scn;
744 str upw;
745
746 if (!url || !url->s)
747 return NULL;
748
749 if (pkg_str_extend(&buf, url->len + 6 + 1) < 0) {
750 LM_ERR("oom\n");
751 return NULL;
752 }
753
754 /* if there's no '@' sign, the URL has no password */
755 at = q_memchr(url->s, '@', url->len);
756 if (!at)
757 goto url_is_safe;
758
759 /* locate the end of the scheme (typical start for the user:password) */
760 slash = q_memchr(url->s, '/', url->len);
761 if (!slash || slash >= at)
762 goto url_is_safe;
763
764 upw.s = slash;
765 upw.len = at - slash;
766
767 /* if the semicolon is missing, the URL has no password (only username) */
768 scn = q_memchr(upw.s, ':', upw.len);
769 if (!scn)
770 goto url_is_safe;
771
772 sprintf(buf.s, "%.*s:xxxxxx@%.*s", (int)(scn - url->s), url->s,
773 (int)(url->len - (at - url->s) - 1), at + 1);
774
775 return buf.s;
776
777url_is_safe:
778 sprintf(buf.s, "%.*s", url->len, url->s);
779 return buf.s;
780}

Callers 15

_db_url_escapeFunction · 0.85
db_cachedb_initFunction · 0.85
child_initFunction · 0.85
mod_initFunction · 0.85
child_initFunction · 0.85
child_initFunction · 0.85
mod_initFunction · 0.85
qr_child_initFunction · 0.85
qr_check_dbFunction · 0.85
child_initFunction · 0.85
mod_initFunction · 0.85
child_initFunction · 0.85

Calls 2

pkg_str_extendFunction · 0.85
q_memchrFunction · 0.85

Tested by

no test coverage detected