diff options
-rw-r--r-- | include/xine/xine_internal.h | 5 | ||||
-rw-r--r-- | src/xine-engine/xine.c | 31 |
2 files changed, 36 insertions, 0 deletions
diff --git a/include/xine/xine_internal.h b/include/xine/xine_internal.h index 543d01c30..437f45a38 100644 --- a/include/xine/xine_internal.h +++ b/include/xine/xine_internal.h @@ -469,6 +469,11 @@ void _x_demux_send_mrl_reference (xine_stream_t *stream, int alternative, void _x_mrl_unescape(char *mrl) XINE_PROTECTED; /* + * Return a copy of mrl without authentication credentials + */ +char *_x_mrl_remove_auth(const char *mrl) XINE_PROTECTED; + +/* * plugin_loader functions * */ 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; |