Permalink
Browse files

updated plugin to use markdown-it instead of remarkable, and updated …

…validateLink method to discard all data-uris, until a solution is developed upstream.
  • Loading branch information...
julianlam committed Mar 30, 2015
1 parent abbd941 commit ab7f2684750882f7baefbfa31db8d5aac71e6ec3
Showing with 14 additions and 3 deletions.
  1. +13 −2 index.js
  2. +1 −1 package.json
@@ -1,7 +1,7 @@
(function() {
"use strict";
var Remarkable = require('remarkable'),
var MarkdownIt = require('markdown-it'),
fs = require('fs'),
path = require('path'),
url = require('url'),
@@ -67,7 +67,18 @@
_self.highlight = _self.config.highlight || true;
delete _self.config.highlight;
parser = new Remarkable(_self.config);
parser = new MarkdownIt(_self.config);
// Override the link validator from MarkdownIt, so you cannot link directly to a data-uri
parser.validateLink = function(url) {
var BAD_PROTOCOLS = [ 'vbscript', 'javascript', 'file', 'data' ];
var str = url.trim().toLowerCase();
if (str.indexOf(':') >= 0 && BAD_PROTOCOLS.indexOf(str.split(':')[0]) >= 0) {
return false;
}
return true;
}
});
},
@@ -18,7 +18,7 @@
"url": "https://github.com/julianlam/nodebb-plugin-markdown/issues"
},
"dependencies": {
"remarkable": "^1.3.0"
"markdown-it": "^4.0.3"
},
"nbbpm": {
"compatibility": "^0.7.0"

0 comments on commit ab7f268

Please sign in to comment.