From: Max Kellermann Date: Wed, 2 Aug 2017 06:33:00 +0000 (+0200) Subject: screen_queue: hide the MPD password in the screen title X-Git-Tag: v0.28~16 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=23041f39c7c7e1d119ffe2f6239cc3a2f1248e1a;p=ncmpc.git screen_queue: hide the MPD password in the screen title Closes #2 --- diff --git a/NEWS b/NEWS index 89bb4a4..157b39d 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,7 @@ ncmpc 0.28 - not yet released * fix crash on lyrics screen * fix memory leak +* hide the MPD password from the queue screen title * build with Meson instead of autotools ncmpc 0.27 - (2017-03-25) diff --git a/src/screen_queue.c b/src/screen_queue.c index d98445d..47eb716 100644 --- a/src/screen_queue.c +++ b/src/screen_queue.c @@ -370,13 +370,28 @@ screen_queue_exit(void) list_window_free(lw); } +/** + * Extract the host portion (without the optional password) from the + * MPD_HOST string. + */ +static const char * +host_without_password(const char *host) +{ + const char *separator = strchr(host, '@'); + if (separator != NULL && separator != host && separator[1] != 0) + host = separator + 1; + + return host; +} + static const char * screen_queue_title(char *str, size_t size) { if (options.host == NULL) return _("Queue"); - g_snprintf(str, size, _("Queue on %s"), options.host); + g_snprintf(str, size, _("Queue on %s"), + host_without_password(options.host)); return str; }