diff --git a/labs/meteor-client/client/views/chat/chat_bar.coffee b/labs/meteor-client/client/views/chat/chat_bar.coffee
index 74d4c20f92..a9ce29fa95 100755
--- a/labs/meteor-client/client/views/chat/chat_bar.coffee
+++ b/labs/meteor-client/client/views/chat/chat_bar.coffee
@@ -158,8 +158,7 @@ Template.tabButtons.helpers
Template.message.helpers
activateBreakLines: (str) ->
- res = str
- res = res.replace /\n/gim, '
'
+ res = str.replace /\n/gim, '
'
res = res.replace /\r/gim, '
'
getHexColor: (c) ->
@@ -170,13 +169,8 @@ Template.message.helpers
# make links received from Flash client clickable in HTML
toClickable: (str) ->
- res = str
- # res = str.replace /<a href='event:/gim, "'
-
- # res = res.replace /<u>/gim, ''
- # res = res.replace /<\/u>/gim, ''
- res
+ res = str.replace /
- res = str
- # First, replace replace all tags with the ascii equivalent
- res = res.replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"');
-
- res = Template.message.toClickable(res)
- res = Template.message.activateBreakLines(res)
+ # First, replace replace all tags with the ascii equivalent (excluding those involved in anchor tags)
+ res = str.replace(/&/g, '&').replace(/<(?![au\/])/g, '<').replace(/([^au])>/g, '$1>').replace(/([^=])"(?!>)/g, '$1"');
+
+ res = Template.message.toClickable res
+ res = Template.message.activateBreakLines res