Code

screen_queue: hide the MPD password in the screen title
authorMax Kellermann <max.kellermann@gmail.com>
Wed, 2 Aug 2017 06:33:00 +0000 (08:33 +0200)
committerMax Kellermann <max.kellermann@gmail.com>
Wed, 2 Aug 2017 06:33:00 +0000 (08:33 +0200)
Closes #2

NEWS
src/screen_queue.c

diff --git a/NEWS b/NEWS
index 89bb4a4c902b24e0529c2b59c899b869a051f906..157b39dadf390e7f6ede7f383fd893cfafc290f7 100644 (file)
--- 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)
index d98445ded49bc0a1a6b3f8e2406e191dcd69dc27..47eb7165eee0404db24505cf1b659124f7c012e6 100644 (file)
@@ -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;
 }