diff --git a/source/Ox/js/HTML.js b/source/Ox/js/HTML.js index 2e6dda15..0c8682fa 100644 --- a/source/Ox/js/HTML.js +++ b/source/Ox/js/HTML.js @@ -5,6 +5,7 @@ Ox.parseEmailAddresses Takes HTML and turns e-mail addresses into links @*/ // fixme: no tests // fixme: shouldn't this be formatEmailAddresses? +// fixme: fails for linked emails Ox.parseEmailAddresses = function(html) { return html.replace( /\b([0-9A-Z\.\+\-_]+@(?:[0-9A-Z\-]+\.)+[A-Z]{2,6})\b/gi, @@ -61,7 +62,7 @@ Ox.parseHTML = (function() { '<\/a>': '' }, img: { - ']*?src="(https?:\/\/.+?)".*?>': '' + ']*?src="((https?:\/\/|\/).+?)".*?>': '' }, rtl: { '': '
', @@ -79,7 +80,7 @@ Ox.parseHTML = (function() { tags = tags || defaultTags; // html = Ox.clean(html); fixme: can this be a parameter? if (tags.indexOf('[]') > -1) { - html = html.replace(/\[(https?:\/\/.+?) (.+?)\]/gi, '$2'); + html = html.replace(/\[((https?:\/\/|\/).+?) (.+?)\]/gi, '$3'); tags = tags.filter(function(tag) { return tag != '[]'; }); @@ -94,8 +95,9 @@ Ox.parseHTML = (function() { }); }); html = Ox.encodeHTML(html); - html = Ox.parseURLs(html); - html = Ox.parseEmailAddresses(html); + //fixme: both fail if urls/emails are already links + //html = Ox.parseURLs(html); + //html = Ox.parseEmailAddresses(html); matches.forEach(function(match, i) { html = html.replace(new RegExp(tab + i + tab, 'gi'), match); }); @@ -146,9 +148,17 @@ Ox.parseURL = (function() { /*@ Ox.parseURLs Takes HTML and turns URLs into links + > Ox.parseURLs('http://foo.com, bar') + 'http://foo.com, bar' + > Ox.parseURLs('http://foo.com/foobar?foo, bar') + 'http://foo.com/foobar?foo, bar' + > Ox.parseURLs('www.foo.com, bar') + 'www.foo.com, bar' + > Ox.parseURLs('http://foo.com etc') + 'http://foo.com etc' @*/ -// fixme: no tests // fixme: shouldn't this be formatURLs? +// fixme: fails for urls inside links Ox.parseURLs = function(html) { return html.replace( /\b((https?:\/\/|www\.).+?)([\.,:;!\?\)\]]*?(\s|$))/gi,