From: Chip Black Date: Thu, 13 Jan 2011 09:59:39 +0000 (-0800) Subject: Whoops, searching and replacing *globally* is important. X-Git-Tag: v1.0-ish~19 X-Git-Url: http://git.bytex64.net/?a=commitdiff_plain;h=02b61f4e1986828cd7b86d2bc448ca9534e5d19f;hp=93ac2090dfae4917cfdd3324d35b60756f5dd8b3;p=blerg.git Whoops, searching and replacing *globally* is important. --- diff --git a/www/js/blerg.js b/www/js/blerg.js index dcb5679..4d56790 100644 --- a/www/js/blerg.js +++ b/www/js/blerg.js @@ -244,17 +244,17 @@ function mangleRecord(record, template) { record.recInt = parseInt(record.record); // Sanitize HTML input - record.data = record.data.replace('&', '&').replace('<', '<').replace('>', '>'); + record.data = record.data.replace(/&/g, '&').replace(//g, '>'); // Turn HTTP URLs into links record.data = record.data.replace(/(\s|^)(https?:\/\/[a-zA-Z0-9.-]*[a-zA-Z0-9](\/([^\s"]*[^.!,;?()\s])?)?)/g, '$1$2'); // Turn markdown links into links - record.data = record.data.replace(/(\s|^)\[([^\]]+)\]\((https?:\/\/[a-zA-Z0-9.-]*[a-zA-Z0-9](\/[^)"]*?)?)\)/, '$1$2'); + record.data = record.data.replace(/(\s|^)\[([^\]]+)\]\((https?:\/\/[a-zA-Z0-9.-]*[a-zA-Z0-9](\/[^)"]*?)?)\)/g, '$1$2'); // Turn *foo* into italics and **foo** into bold - record.data = record.data.replace(/(\s)\*\*([^*]+)\*\*(\s)/, '$1$2$3'); - record.data = record.data.replace(/(\s)\*([^*]+)\*(\s)/, '$1$2$3'); + record.data = record.data.replace(/(\s)\*\*([^*]+)\*\*(\s)/g, '$1$2$3'); + record.data = record.data.replace(/(\s)\*([^*]+)\*(\s)/g, '$1$2$3'); // Turn refs and tags into links record.data = record.data.replace(/(\s|^)#(\w+)/g, '$1#$2');