1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Fixed bug in tinyurl

This commit is contained in:
James Booth 2012-07-29 21:32:04 +01:00
parent 8f983c0484
commit fe12352b57
3 changed files with 23 additions and 16 deletions

1
.gitignore vendored
View File

@ -10,6 +10,7 @@ profanity
*.swp *.swp
testsuite testsuite
tags tags
cscope.out
.deps/ .deps/
build-aux/ build-aux/
Makefile Makefile

View File

@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script. # Process this file with autoconf to produce a configure script.
AC_PREREQ([2.65]) 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_SRCDIR([src/main.c])
AC_CONFIG_HEADERS([src/config.h]) AC_CONFIG_HEADERS([src/config.h])
AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_AUX_DIR([build-aux])

View File

@ -283,23 +283,29 @@ _cmd_msg(const char * const inp)
static gboolean static gboolean
_cmd_tiny(const char * const inp) _cmd_tiny(const char * const inp)
{ {
char *url = strndup(inp+6, strlen(inp)-6); if (strlen(inp) > 6) {
char *url = strndup(inp+6, strlen(inp)-6);
if (!tinyurl_valid(url)) { if (!tinyurl_valid(url)) {
GString *error = g_string_new("/tiny, badly formed URL: "); GString *error = g_string_new("/tiny, badly formed URL: ");
g_string_append(error, url); g_string_append(error, url);
cons_bad_show(error->str); cons_bad_show(error->str);
g_string_free(error, TRUE); g_string_free(error, TRUE);
} else if (win_in_chat()) { free(url);
char *tiny = tinyurl_get(url); } else if (win_in_chat()) {
char *recipient = win_get_recipient(); char *tiny = tinyurl_get(url);
jabber_send(tiny, recipient); char *recipient = win_get_recipient();
win_show_outgoing_msg("me", recipient, tiny); jabber_send(tiny, recipient);
free(recipient); win_show_outgoing_msg("me", recipient, tiny);
free(tiny); free(recipient);
free(url); free(tiny);
free(url);
} else {
cons_bad_command(inp);
free(url);
}
} else { } else {
cons_bad_command(inp); cons_show("usage: /tiny url");
} }
return TRUE; return TRUE;