diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | src/command.c | 38 |
3 files changed, 24 insertions, 17 deletions
diff --git a/.gitignore b/.gitignore index 4c8d56d5..e27dfb93 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ profanity *.swp testsuite tags +cscope.out .deps/ build-aux/ Makefile diff --git a/configure.ac b/configure.ac index cff84ff4..bbed40a8 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ([2.65]) -AC_INIT([profanity], [0.1.3], [boothj5web@gmail.com]) +AC_INIT([profanity], [0.1.4], [boothj5web@gmail.com]) AC_CONFIG_SRCDIR([src/main.c]) AC_CONFIG_HEADERS([src/config.h]) AC_CONFIG_AUX_DIR([build-aux]) diff --git a/src/command.c b/src/command.c index 3bddc895..30c76b12 100644 --- a/src/command.c +++ b/src/command.c @@ -283,23 +283,29 @@ _cmd_msg(const char * const inp) static gboolean _cmd_tiny(const char * const inp) { - char *url = strndup(inp+6, strlen(inp)-6); - - if (!tinyurl_valid(url)) { - GString *error = g_string_new("/tiny, badly formed URL: "); - g_string_append(error, url); - cons_bad_show(error->str); - g_string_free(error, TRUE); - } else if (win_in_chat()) { - char *tiny = tinyurl_get(url); - char *recipient = win_get_recipient(); - jabber_send(tiny, recipient); - win_show_outgoing_msg("me", recipient, tiny); - free(recipient); - free(tiny); - free(url); + if (strlen(inp) > 6) { + char *url = strndup(inp+6, strlen(inp)-6); + + if (!tinyurl_valid(url)) { + GString *error = g_string_new("/tiny, badly formed URL: "); + g_string_append(error, url); + cons_bad_show(error->str); + g_string_free(error, TRUE); + free(url); + } else if (win_in_chat()) { + char *tiny = tinyurl_get(url); + char *recipient = win_get_recipient(); + jabber_send(tiny, recipient); + win_show_outgoing_msg("me", recipient, tiny); + free(recipient); + free(tiny); + free(url); + } else { + cons_bad_command(inp); + free(url); + } } else { - cons_bad_command(inp); + cons_show("usage: /tiny url"); } return TRUE; |