Skip to content

Commit

Permalink
updated plugin to use markdown-it instead of remarkable, and updated …
Browse files Browse the repository at this point in the history
…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 ab7f268
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 13 additions & 2 deletions index.js
@@ -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'),
Expand Down Expand Up @@ -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;
}
});
},

Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -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"
Expand Down

0 comments on commit ab7f268

Please sign in to comment.