changeset 28968:5f6571bb128d

Fix sending '/messages/like/this '. Fixes #10114.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Wed, 03 Feb 2010 19:45:23 +0000
parents 36bae5f00d32
children 757a386a5c93
files pidgin/gtkconv.c
diffstat 1 files changed, 9 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/gtkconv.c	Wed Feb 03 18:56:03 2010 +0000
+++ b/pidgin/gtkconv.c	Wed Feb 03 19:45:23 2010 +0000
@@ -497,17 +497,15 @@
 						prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl);
 
 					if ((prpl_info != NULL) && (prpl_info->options & OPT_PROTO_SLASH_COMMANDS_NATIVE)) {
-						char *firstspace;
-						char *slash;
-
-						firstspace = strchr(cmdline, ' ');
-						if (firstspace != NULL) {
-							slash = strrchr(firstspace, '/');
-						} else {
-							slash = strchr(cmdline, '/');
-						}
-
-						if (slash == NULL) {
+						char *spaceslash;
+
+						/* If the first word in the entered text has a '/' in it, then the user
+						 * probably didn't mean it as a command. So send the text as message. */
+						spaceslash = cmdline;
+						while (*spaceslash && *spaceslash != ' ' && *spaceslash != '/')
+							spaceslash++;
+
+						if (*spaceslash != '/') {
 							purple_conversation_write(conv, "", _("Unknown command."), PURPLE_MESSAGE_NO_LOG, time(NULL));
 							retval = TRUE;
 						}