[Phpfreechat-svn] SF.net SVN: phpfreechat: [1137] trunk/data/public/js/pfcclient.js
Status: Beta
Brought to you by:
kerphi
From: <gpi...@us...> - 2007-08-21 01:46:07
|
Revision: 1137 http://phpfreechat.svn.sourceforge.net/phpfreechat/?rev=1137&view=rev Author: gpinzone Date: 2007-08-20 18:46:09 -0700 (Mon, 20 Aug 2007) Log Message: ----------- Fix for parse smileys: No longer replace smileys inside of HTML tags. Tested on Firefox only. Modified Paths: -------------- trunk/data/public/js/pfcclient.js Modified: trunk/data/public/js/pfcclient.js =================================================================== --- trunk/data/public/js/pfcclient.js 2007-08-20 21:22:57 UTC (rev 1136) +++ trunk/data/public/js/pfcclient.js 2007-08-21 01:46:09 UTC (rev 1137) @@ -1458,8 +1458,11 @@ var sl = smileys.keys(); for(var i = 0; i < sl.length; i++) { - rx = new RegExp(RegExp.escape(sl[i]),'g'); - msg = msg.replace(rx, '<img src="'+ smileys[sl[i]] +'" alt="' + sl[i] + '" title="' + sl[i] + '" />'); + // Emulate negative lookbehind in JavaScript. + // We don't want to replace smiley strings inside of tags. + // See http://blog.stevenlevithan.com/archives/mimic-lookbehind-javascript for more info. + rx = new RegExp('(<[^>]*)?' + RegExp.escape(sl[i]),'g'); + msg = msg.replace(rx, function($0, $1){ return $1 ? $0 : $1 + '<img src="'+ smileys[sl[i]] +'" alt="' + sl[i] + '" title="' + sl[i] + '" />'; }); } // try to parse nickname for highlighting This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |