From d934dfbc4afa3127e46394ed89b7848b25f4c28f Mon Sep 17 00:00:00 2001 From: tavriaforever Date: Mon, 20 Jul 2015 13:42:18 +0300 Subject: [PATCH] Fixed a bug not correctly check whether the file contains html --- src/util.js | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/util.js b/src/util.js index 9c33575..c0c2e8a 100644 --- a/src/util.js +++ b/src/util.js @@ -29,22 +29,14 @@ exports.getStorageConfiguration = function (config, env) { return _.extend({}, common, config[env]); }; -// this method has been taken from cheerio module code -// https://github.com/cheeriojs/cheerio/blob/master/lib/cheerio.js#L122 /** * Checks if given string is html string * @param {String} str (can be markdown or html string) * @returns {boolean} */ exports.isHtml = function (str) { - if (str.charAt(0) === '<' && - str.charAt(str.length - 1) === '>' && - str.length >= 3) { - return true; - } - - var match = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/.exec(str); - return !!(match && match[1]); + var length = str.length; + return str.charAt(0) === '<' && str.charAt(length - 1) === '>' && length >= 3; }; /** @@ -60,7 +52,7 @@ exports.mdToHtml = function (content) { return md(content, { gfm: true, pedantic: false, - sanitize: false, + sanitize: true, renderer: bmdr.getRenderer() }); };