[Phpfreechat-svn] SF.net SVN: phpfreechat: [1147] trunk/data/public/js/pfcclient.js
Status: Beta
Brought to you by:
kerphi
From: <gpi...@us...> - 2007-08-27 16:53:29
|
Revision: 1147 http://phpfreechat.svn.sourceforge.net/phpfreechat/?rev=1147&view=rev Author: gpinzone Date: 2007-08-26 16:06:21 -0700 (Sun, 26 Aug 2007) Log Message: ----------- Updated double-space search and replace to use positive and negative lookahead. Modified Paths: -------------- trunk/data/public/js/pfcclient.js Modified: trunk/data/public/js/pfcclient.js =================================================================== --- trunk/data/public/js/pfcclient.js 2007-08-26 16:23:20 UTC (rev 1146) +++ trunk/data/public/js/pfcclient.js 2007-08-26 23:06:21 UTC (rev 1147) @@ -1435,9 +1435,9 @@ msg = msg.replace(rx, '$1'); } - // replace double spaces by entity - rx = new RegExp(' ','g'); - msg = msg.replace(rx, ' '); + // Replace double spaces outside of tags by " " entity. + rx = new RegExp(' (?= )(?![^<]*>)','g'); + msg = msg.replace(rx, ' '); // try to parse bbcode rx = new RegExp('\\[b\\](.+?)\\[\/b\\]','ig'); @@ -1471,7 +1471,7 @@ { // We don't want to replace smiley strings inside of tags. // Use negative lookahead to search for end of tag. - rx = new RegExp(RegExp.escape(sl[i]) + "(?![^<]*>)",'g'); + rx = new RegExp(RegExp.escape(sl[i]) + '(?![^<]*>)','g'); msg = msg.replace(rx, '<img src="'+ smileys[sl[i]] +'" alt="' + sl[i] + '" title="' + sl[i] + '" />'); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |