diff options
author | Petri Hintukainen <phintuka@users.sourceforge.net> | 2013-11-06 12:30:51 +0200 |
---|---|---|
committer | Petri Hintukainen <phintuka@users.sourceforge.net> | 2013-11-06 12:30:51 +0200 |
commit | 3931f4c1f5e7b7a38dbd92ee57112509510054d5 (patch) | |
tree | 2b5d2ce3e5a52b30538be3bc43caa77b148d98d2 /src | |
parent | ccd5f63309e44878cf13c5bc7e88b1b95fd6c29a (diff) | |
download | xine-lib-3931f4c1f5e7b7a38dbd92ee57112509510054d5.tar.gz xine-lib-3931f4c1f5e7b7a38dbd92ee57112509510054d5.tar.bz2 |
Add _x_mrl_remove_auth(): return a copy of mrl without authentication credentials
Diffstat (limited to 'src')
-rw-r--r-- | src/xine-engine/xine.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c index 4bf7bba00..c8484bdde 100644 --- a/src/xine-engine/xine.c +++ b/src/xine-engine/xine.c @@ -809,6 +809,37 @@ void _x_mrl_unescape(char *mrl) { mrl[len] = 0; } +char *_x_mrl_remove_auth(const char *mrl_in) +{ + char *mrl = strdup(mrl_in); + char *auth, *p, *at, *host_end; + + /* parse protocol */ + if (!(p = strchr(mrl, ':'))) { + /* no protocol means plain filename */ + return mrl; + } + + p++; /* skip ':' */ + if (*p == '/') p++; + if (*p == '/') p++; + + /* authorization (user[:pass]@hostname) */ + auth = p; + host_end = strchr(p, '/'); + while ((at = strchr(p, '@')) && at < host_end) { + p = at + 1; /* skip '@' */ + } + + if (p != auth) { + while (p[-1]) { + *auth++ = *p++; + } + } + + return mrl; +} + void _x_flush_events_queues (xine_stream_t *stream) { xine_list_iterator_t ite; |