diff --git a/node_modules/resanitize/resanitize.js b/node_modules/resanitize/resanitize.js index 694b4f48..eada0f69 100644 --- a/node_modules/resanitize/resanitize.js +++ b/node_modules/resanitize/resanitize.js @@ -195,13 +195,13 @@ function stripUnsafeAttrs (str) { } module.exports.stripUnsafeAttrs = stripUnsafeAttrs; -function stripUnsafeTags (str) { +function stripUnsafeTags (str, tags) { // var el = /<(?:wbr|form|input|font|blink|script|style|comment|plaintext|xmp|link|listing|meta|body|frame|frameset)\b/; var ct = 0, max = 2; // Prohibited elements - var otherTags = ['wbr','style', 'comment', 'plaintext', 'xmp', 'listing', + var otherTags = tags || ['wbr','style', 'comment', 'plaintext', 'xmp', 'listing', // 以下是evernote禁止的 'applet','base','basefont','bgsound','blink','body','button','dir','embed','fieldset','frameset','head', 'html','iframe','ilayer','input','isindex','label','layer','legend','link','marquee','menu','meta','noframes', diff --git a/public/plugins/export_evernote/plugin.js b/public/plugins/export_evernote/plugin.js index 51980d36..242adb04 100644 --- a/public/plugins/export_evernote/plugin.js +++ b/public/plugins/export_evernote/plugin.js @@ -19,9 +19,8 @@ Before submitting HTML content over the EDAM API the client application is expec */ define(function() { - var async = require('async'); - - var enml = nodeRequire('./public/plugins/export_evernote/enml'); + var async; // = require('async'); + var enml; // = nodeRequire('./public/plugins/export_evernote/enml'); //============== // tpls @@ -93,6 +92,12 @@ define(function() { _inited: false, init: function() { var me = this; + if (me._inited) { + return; + } + async = require('async'); + enml= nodeRequire('./public/plugins/export_evernote/enml'); + me._inited = true; }, @@ -547,6 +552,7 @@ define(function() { }, click: (function() { return function(noteIds) { + me.init(); me.exportEvernote(noteIds); } })() @@ -560,6 +566,7 @@ define(function() { }, click: (function() { return function(notebookId) { + me.init(); me.exportEvernoteForNotebook(notebookId); } })() diff --git a/public/plugins/export_html/plugin.js b/public/plugins/export_html/plugin.js index 89c0cad2..7af18a3c 100644 --- a/public/plugins/export_html/plugin.js +++ b/public/plugins/export_html/plugin.js @@ -5,7 +5,7 @@ * 注意, fs.existsSync总返回false, readFileSync可用 */ define(function() { - var async = require('async'); + var async; // = require('async'); var exportHTML = { langs: { @@ -36,6 +36,10 @@ define(function() { _inited: false, init: function() { var me = this; + if (me._inited) { + return; + } + async = require('async'); me._inited = true; }, @@ -342,6 +346,7 @@ define(function() { }, click: (function() { return function(noteIds) { + me.init(); me.exportHTML(noteIds); } })() @@ -355,6 +360,7 @@ define(function() { }, click: (function() { return function(notebookId) { + me.init(); me.exportHTMLForNotebook(notebookId); } })() diff --git a/public/plugins/export_leanote/plugin.js b/public/plugins/export_leanote/plugin.js index 5e83d941..6df94f78 100644 --- a/public/plugins/export_leanote/plugin.js +++ b/public/plugins/export_leanote/plugin.js @@ -27,7 +27,8 @@ * */ define(function() { - var async = require('async'); + var async; // = require('async'); + var resanitize; // = require('resanitize'); //=========== // start @@ -61,6 +62,13 @@ define(function() { _inited: false, init: function() { var me = this; + if (me._inited) { + return; + } + + async = require('async'); + resanitize = require('resanitize'); + me._inited = true; }, @@ -89,6 +97,21 @@ define(function() { return filename; }, + fixContent: function (content) { + // srip unsage attrs + var unsafeAttrs = ['id', , /on\w+/i, /data-\w+/i, 'clear', 'target']; + content = content.replace(/<([^ >]+?) [^>]*?>/g, resanitize.filterTag(resanitize.stripAttrs(unsafeAttrs))); + + // strip unsafe tags + content = resanitize.stripUnsafeTags(content, + ['wbr','style', 'comment', 'plaintext', 'xmp', 'listing', + 'applet','base','basefont','bgsound','blink','body','button','dir','embed','fieldset','frameset','head', + 'html','iframe','ilayer','input','isindex','label','layer','legend','link','marquee','menu','meta','noframes', + 'noscript','object','optgroup','option','param','plaintext','script','select','style','textarea','xml'] + ); + return content; + }, + getLeanoteTime: function(t) { // 20151026T033928Z // 2015 10 26 T 03 39 28 Z @@ -121,7 +144,7 @@ define(function() { var noteInfo = { title: note.Title, - content: content, + content: me.fixContent(content), tags: note.Tags, author: Api.userService.email || Api.userService.username || '', isMarkdown: note.IsMarkdown, @@ -537,6 +560,7 @@ define(function() { }, click: (function() { return function(noteIds) { + me.init(); me.exportLeanote(noteIds); } })() @@ -550,6 +574,7 @@ define(function() { }, click: (function() { return function(notebookId) { + me.init(); me.exportLeanoteForNotebook(notebookId); } })() diff --git a/public/plugins/import_evernote/plugin.js b/public/plugins/import_evernote/plugin.js index 5899074b..ae3fa8e9 100644 --- a/public/plugins/import_evernote/plugin.js +++ b/public/plugins/import_evernote/plugin.js @@ -4,7 +4,7 @@ * @date 2015/04/09 */ define(function() { - var importService = nodeRequire('./public/plugins/import_evernote/import'); + var importService; // = nodeRequire('./public/plugins/import_evernote/import'); var evernote = { @@ -57,12 +57,6 @@ define(function() {