diff --git a/client/index.html b/client/index.html
index 0e5ffc82..e50fcbec 100644
--- a/client/index.html
+++ b/client/index.html
@@ -114,7 +114,7 @@
{{time}}
{{from}}
{{type}}
- {{text}}
+ {{{uri text}}}
{{/each}}
diff --git a/client/js/chat.js b/client/js/chat.js
index 68c54fac..1331b2c0 100644
--- a/client/js/chat.js
+++ b/client/js/chat.js
@@ -35,13 +35,6 @@ $(function() {
return tpl[id](json);
}
- Handlebars.registerHelper(
- "partial",
- function(id) {
- return new Handlebars.SafeString(render(id, this));
- }
- );
-
function handleEvent(event, json) {
var data = json.data;
switch (event) {
@@ -244,12 +237,6 @@ $(function() {
chat.on("focus", "input[type=text]", function() {
$(this).closest(".window").find(".messages").scrollToBottom();
});
-
- function uri(text) {
- return URI.withinString(text, function(url) {
- return "" + url + "";
- });
- }
var highest = 1;
$.fn.bringToTop = function() {
@@ -262,4 +249,34 @@ $(function() {
.removeClass("active")
.end();
};
+
+ function uri(text) {
+ return URI.withinString(text, function(url) {
+ return "" + url + "";
+ });
+ }
+
+ function escape(string) {
+ var e = {
+ "<": "<",
+ ">": ">",
+ };
+ return string.replace(/[<>]/g, function (s) {
+ return e[s];
+ });
+ }
+
+ Handlebars.registerHelper(
+ "uri",
+ function(text) {
+ return uri(escape(text));
+ }
+ );
+
+ Handlebars.registerHelper(
+ "partial",
+ function(id) {
+ return new Handlebars.SafeString(render(id, this));
+ }
+ );
});