adium 2446:8e27a66986b3: Don't infinite loop if an incoming mess...

commits at adium.im commits at adium.im
Tue Jun 2 19:44:57 UTC 2009


details:	http://hg.adium.im/adium/rev/8e27a66986b3
revision:	2446:8e27a66986b3
author:		Zachary West <zacw at adium.im>
date:		Tue Jun 02 15:44:48 2009 -0400

Don't infinite loop if an incoming message contains %message%.

diffs (33 lines):

diff -r 17d04ce06b25 -r 8e27a66986b3 Plugins/WebKit Message View/AIWebkitMessageViewStyle.m
--- a/Plugins/WebKit Message View/AIWebkitMessageViewStyle.m	Tue Jun 02 13:44:31 2009 -0400
+++ b/Plugins/WebKit Message View/AIWebkitMessageViewStyle.m	Tue Jun 02 15:44:48 2009 -0400
@@ -698,6 +698,8 @@
 								  [(AIListContact *)contentSource parentContact] :
 								  contentSource);
 
+	NSLog(@"Message = %@", content.message);
+	
 	/*
 		htmlEncodedMessage is only encoded correctly for AIContentMessages
 		but we do it up here so that we can check for RTL/LTR text below without
@@ -723,6 +725,8 @@
 													 bodyBackground:NO
 										        allowJavascriptURLs:NO];
 	
+	NSLog(@"html encoded msg = %@", htmlEncodedMessage);
+	
 	if (styleVersion >= 4)
 		htmlEncodedMessage = [adium.contentController filterHTMLString:htmlEncodedMessage
 															   direction:[content isOutgoing] ? AIFilterOutgoing : AIFilterIncoming
@@ -1048,7 +1052,10 @@
 		range = [inString rangeOfString:@"%message%"];
 		while(range.location != NSNotFound) {
 			[inString safeReplaceCharactersInRange:range withString:htmlEncodedMessage];
-			range = [inString rangeOfString:@"%message%" options:NSLiteralSearch range:NSMakeRange(NSMaxRange(range), inString.length - NSMaxRange(range))];
+			range = [inString rangeOfString:@"%message%"
+									options:NSLiteralSearch
+									  range:NSMakeRange(range.location + htmlEncodedMessage.length,
+														inString.length - range.location - htmlEncodedMessage.length)];
 		} 
 		
 		// Topic replacement (if applicable)




More information about the commits mailing list