From b637ce5df9658fb03816317ee4f1b8aed7aafe0e Mon Sep 17 00:00:00 2001 From: Matthew Scragg Date: Sat, 20 Sep 2014 17:15:12 -0500 Subject: [PATCH] fixes #18 relative link bug --- realms/static/css/style.css | 3 --- realms/static/js/main.js | 14 +++++++++++--- setup.py | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/realms/static/css/style.css b/realms/static/css/style.css index 8ad3ab2..ea37b84 100644 --- a/realms/static/css/style.css +++ b/realms/static/css/style.css @@ -1,6 +1,3 @@ -body { -} - .navbar { height: 50px !important; min-height: 49px !important; diff --git a/realms/static/js/main.js b/realms/static/js/main.js index 278785d..3a8a80f 100644 --- a/realms/static/js/main.js +++ b/realms/static/js/main.js @@ -58,7 +58,7 @@ hljs.initHighlightingOnLoad(); var MDR = { meta: null, md: null, - sanitize: true, // Override + sanitize: false, // Override parse: function(md){ return marked(md); }, convert: function(md, sanitize){ if (this.sanitize !== null) { @@ -75,9 +75,17 @@ var MDR = { if (sanitize) { // Causes some problems with inline styles html = html_sanitize(html, function(url) { - if(/^(\/|https?:\/\/)/.test(url)) { - return url + try { + var prot = decodeURIComponent(unescape(url)) + .replace(/[^\w:]/g, '') + .toLowerCase(); + } catch (e) { + return ''; } + if (prot.indexOf('javascript:') === 0) { + return ''; + } + return prot; }, function(id){ return id; }); diff --git a/setup.py b/setup.py index 737eb81..eade28f 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ with open('README.md') as f: with open('requirements.txt') as f: required = f.read().splitlines() -VERSION = '0.1.9' +VERSION = '0.1.10' CLASSIFIERS = [ 'Intended Audience :: Developers',