Do not put a username in telnets urls when the field is empty - sacc - sacc(omys), simple console gopher client
git clone git://bitreich.org/sacc/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/sacc/
Log
Files
Refs
Tags
LICENSE
---
commit bab7585c38f70040c68865455e3fafa552cf9f6c
parent cffc2d4ac776d81b9e8a8083cee8064cd3f0d954
Author: Quentin Rameau 
Date:   Sat, 18 Aug 2018 14:51:58 +0200

Do not put a username in telnets urls when the field is empty

Thanks to Hiltjo for the hint!

Diffstat:
  M sacc.c                              |       6 ++++--

1 file changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/sacc.c b/sacc.c
@@ -679,14 +679,16 @@ dig(Item *entry, Item *item)
                 downloaditem(item);
                 return 0;
         case '8':
-                if (asprintf(&plumburi, "telnet://%s@%s:%s", item->selector,
+                if (asprintf(&plumburi, "telnet://%s%s%s:%s",
+                             item->selector, item->selector ? "@" : "",
                              item->host, item->port) < 0)
                         return 0;
                 plumb(plumburi);
                 free(plumburi);
                 return 0;
         case 'T':
-                if (asprintf(&plumburi, "tn3270://%s@%s:%s", item->selector,
+                if (asprintf(&plumburi, "tn3270://%s%s%s:%s",
+                             item->selector, item->selector ? "@" : "",
                              item->host, item->port) < 0)
                         return 0;
                 plumb(plumburi);