{"id":246,"date":"2020-06-14T13:47:41","date_gmt":"2020-06-14T04:47:41","guid":{"rendered":"http:\/\/localhost:8000\/?p=246"},"modified":"2021-01-16T13:53:25","modified_gmt":"2021-01-16T04:53:25","slug":"vue-typescript-markdown-editor","status":"publish","type":"post","link":"http:\/\/localhost:8000\/2020\/06\/vue-typescript-markdown-editor.html","title":{"rendered":"vue+typescript\u306e\u30a2\u30d7\u30ea\u306bmarkdown editor\u3092\u5c0e\u5165"},"content":{"rendered":"
vue + typescript\u3067\u4f5c\u3063\u3066\u3044\u308b\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u30a2\u30d7\u30ea\u306bmarkdown editor\u3092\u5c0e\u5165\u3057\u305f\u306e\u3067\u5c11\u3057\u7d39\u4ecb\u3057\u307e\u3059\u3002 2020\u5e746\u6708\u6642\u70b9\u3067star\u6570\u30823.9k\u3042\u308a\u5b9f\u7e3e\u5341\u5206\u307d\u304b\u3063\u305f\u306e\u3067\u307e\u305a\u306f\u3053\u308c\u3092\u8a66\u3057\u307e\u3057\u305f\u3002<\/p>\n \u3053\u3061\u3089<\/a>\u3092\u30d9\u30fc\u30b9\u306b\u3084\u3063\u3066\u3044\u304f\u308f\u3051\u3067\u3059\u304c\u3001typescript\uff0b\u958b\u767a\u6642\u306fnode_modules\u30fb\u672c\u756a\u306fCDN\u3068\u3044\u3046\u524d\u63d0\u3067\u5c0e\u5165\u624b\u9806\u3092\u8a18\u8f09\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n \u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3001<\/p>\n \u6b21\u306b\u3001 \u3055\u3089\u306b\u3001\u672c\u756a\u7528\u306bhtml\u3067CDN\u304b\u3089CSS\u3068\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u8aad\u307f\u8fbc\u3093\u3067\u304a\u304d\u307e\u3059\u3002<\/p>\n MarkdownEditor \u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u4f5c\u308a\u307e\u3059\u3002\u3053\u3053\u3067\u306f\u30a8\u30c7\u30a3\u30bf\u6a5f\u80fd\u3060\u3051\u3092\u8a18\u8f09\u3057\u3066\u307e\u3059\u3002 \u3042\u3068\u306f\u597d\u304d\u306a\u3068\u3053\u308d\u306bMarkdownEditor\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u5dee\u3057\u8fbc\u3080\u3060\u3051\u3067\u3059\u3002\u3068\u3066\u3082\u7c21\u5358\u3067\u3059\u306d\u3002<\/p>\n \u5c0e\u5165\u306f\u7c21\u5358\u306a\u306e\u3067\u3059\u304c\u3001 More Info\u306b\u66f8\u3044\u3066\u3042\u308b[https:\/\/npmjs.com\/advisories\/1169<\/a>] \u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3068\u3001github issue<\/a> \u3078\u306e\u30ea\u30f3\u30af\u304c\u8cbc\u3063\u3066\u3042\u3063\u3066\u3001\u306a\u306b\u3084\u3089\u307e\u3060\u89e3\u6c7a\u3057\u3066\u306a\u3044\u6a21\u69d8\u3067\u3059\u3002<\/p>\n \u5b9f\u969b\u306b\u3001markdown editor\u306etextarea\u306b mavonEditor\u306fxss-options\u3092\u63d0\u4f9b\u3057\u3066\u3044\u307e\u3059\u3002document\u306b\u3042\u307e\u308a\u8a18\u8f09\u304c\u306a\u3044\u306e\u3067\u3059\u304c\u3001\u5165\u529b\u5024\u3092js-xss<\/a>\u3092\u4f7f\u3063\u3066\u30b5\u30cb\u30bf\u30a4\u30ba\u3057\u3066\u304f\u308c\u307e\u3059\u3002js-xss\u306f\u3053\u306e\u30c1\u30fc\u30c8\u30b7\u30fc\u30c8<\/a>\u306eXSS\u306b\u306f\u5bfe\u5fdc\u3057\u3066\u3044\u308b\u3088\u3046\u306a\u306e\u3067\u3001\u81ea\u524d\u3067\u4f55\u304b\u3084\u308b\u3088\u308a\u306f\u826f\u3055\u305d\u3046\u3067\u3059\u3002<\/p>\n \u8a2d\u5b9a\u65b9\u6cd5\u306f\u7c21\u5358\u3067\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3059\u308b\u3060\u3051\u3067\u3059\u3002<\/p>\n \u6307\u5b9a\u3067\u304d\u308b\u30aa\u30d7\u30b7\u30e7\u30f3\u306f\u3053\u3061\u3089<\/a>\u3092\u53c2\u8003\u306b\u3059\u308b\u3068\u3001\u30b5\u30cb\u30bf\u30a4\u30ba\u5bfe\u8c61\u5916\u306b\u3059\u308b\u30bf\u30b0\u306e\u30db\u30ef\u30a4\u30c8\u30ea\u30b9\u30c8\u3092\u767b\u9332\u3057\u305f\u308a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u307f\u305f\u3044\u3067\u3059\u304c\u3001\u3068\u308a\u3042\u3048\u305a\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u307e\u307e\u3067\u8a66\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n \u5b9f\u969b\u306b\u524d\u8ff0\u306e\u30c1\u30fc\u30c8\u30b7\u30fc\u30c8<\/a>\u306e\u5185\u5bb9\u3092\u305d\u306e\u307e\u307e\u8cbc\u308a\u4ed8\u3051\u3066\u5b9f\u884c\u3057\u3066\u307f\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u4e8c\u3064\u306e\u30d1\u30bf\u30fc\u30f3\u3067\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f\u3002<\/p>\n \u3053\u306e\u4e8c\u3064\u306b\u3064\u3044\u3066\u3082\u3001\u3071\u3063\u3068\u898bissue\u306b\u306f\u4e0a\u304c\u3063\u3066\u307e\u305b\u3093\u3067\u3057\u305f\u304c\u3001\u958b\u767a\u3082\u7d9a\u3044\u3066\u3044\u308b\u3088\u3046\u306a\u306e\u3067\u3044\u305a\u308c\u4fee\u6b63\u3055\u308c\u308b\u3053\u3068\u3092\u671f\u5f85\u3057\u3066\u3082\u826f\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002<\/p>\n \u3067\u3001\u3053\u308c\u3067\u5b8c\u4e86\u3068\u3057\u305f\u3044\u3068\u3053\u308d\u3067\u3059\u304c\u3001mavonEditor\u306exss-options\u306b\u306f\u6b20\u9665\u304c\u3042\u308a\u307e\u3059\u3002 \u3053\u306e\u30b5\u30cb\u30bf\u30a4\u30ba\u51e6\u7406\u3092\u30d7\u30ec\u30d3\u30e5\u30fc\u6642\u3084@change\u3084@save\u306e\u30a4\u30d9\u30f3\u30c8\u3067\u53d6\u5f97\u3067\u304d\u308bHTML\u306b\u3060\u3051\u9069\u7528\u3059\u308b\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u63a2\u3057\u305f\u306e\u3067\u3059\u304c\u898b\u5f53\u305f\u308a\u307e\u305b\u3093\u3002 \u3068\u3044\u3046\u308f\u3051\u3067\u30012020\u5e746\u6708\u6642\u70b9\u306exss-options\u306e\u4ed5\u69d8\u3060\u3068\u53b3\u3057\u3044\u3068\u5224\u65ad\u3057\u3001xss-options\u3092\u4f7f\u3046\u306e\u306f\u8ae6\u3081\u307e\u3057\u305f\u3002 xss-options\u3092\u4f7f\u308f\u306a\u3044\u5834\u5408\u3001\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u30d7\u30ec\u30d3\u30e5\u30fc\u3067HTML\u304c\u751f\u6210\u3055\u308c\u30b9\u30af\u30ea\u30d7\u30c8\u304c\u5b9f\u884c\u3055\u308c\u308b\u306e\u304c\u90aa\u9b54\u3067\u3059\u3002 \u3068\u3044\u3046\u308f\u3051\u3067\u3001\u3053\u3061\u3089\u3082\u8ae6\u3081\u307e\u3057\u305f\u3002<\/p>\n \u7d50\u5c40\u3001XSS\u30c1\u30fc\u30c8\u30b7\u30fc\u30c8\u306e\u5185\uff12\u4ef6\u306f\u5bfe\u5fdc\u3067\u304d\u3066\u306a\u3044\u3053\u3068\u3001\u73fe\u72b6\u3067\u306fxss-options\u3092\u4f7f\u3046\u3068\u5165\u529b\u5024\u305d\u306e\u3082\u306e\u304c\u30b5\u30cb\u30bf\u30a4\u30ba\u3055\u308c\u3066\u3057\u307e\u3046\u3053\u3068\u3001\u304c\u6c17\u306b\u306a\u308b\u306e\u3067mavonEditor\u306e\u5c0e\u5165\u306f\u898b\u9001\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002 <\/p>\n \u6700\u521d\u306bSimpleMDE<\/a>\u3092\u898b\u3064\u3051\u307e\u3057\u305f\u3002\u3053\u308c\u306f\u30a8\u30c7\u30a3\u30bf\u30fc\u6a5f\u80fd\u3082\u3042\u308apreview\u6642\u306eHTML\u306e\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3082\u3067\u304d\u305d\u3046\u306a\u306e\u3067\u3059\u304c\u3001\u5982\u4f55\u305b\u3093\u958b\u767a\u304c\u6b62\u307e\u3063\u3066\u3057\u307e\u3063\u3066\u3044\u307e\u3059\u3002 \u3053\u3061\u3089\u3082\u3001typescript\uff0b\u958b\u767a\u6642\u306fnode_modules\u30fb\u672c\u756a\u306fCDN\u3068\u3044\u3046\u524d\u63d0\u3067\u5c0e\u5165\u624b\u9806\u3092\u8a18\u8f09\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n EasyMDE\u3001\u30b5\u30cb\u30bf\u30a4\u30ba\u7528\u306eDOMPurify<\/a>\u3001HTML\u5909\u63db\u7528\u306emarked<\/a>\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/p>\n \u307e\u305a\u3001 \u3055\u3089\u306b\u3001\u672c\u756a\u7528\u306bhtml\u3067CDN\u304b\u3089CSS\u3068\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u8aad\u307f\u8fbc\u3093\u3067\u304a\u304d\u307e\u3059\u3002 \u307e\u305f\u3001 \u3053\u308c\u3092\u8a2d\u5b9a\u3057\u306a\u3044\u3068\u3001\u5b9f\u969b\u306beasymde\u3092import\u3057\u3088\u3046\u3068\u3059\u308b\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3059\u3002<\/p>\n TS1259: Module '"\/xxxx\/xxxx\/node_modules\/easymde\/types\/easymde"' can only be default-imported using the 'allowSyntheticDefaultImports' flag<\/p>\n<\/blockquote>\n \u305d\u3057\u3066\u3001\u672c\u547d\u306e MarkdownEditor \u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u4f5c\u308a\u307e\u3059\u3002<\/p>\n \u30dd\u30a4\u30f3\u30c8\u306f\u4ee5\u4e0b\u3067\u3059\u3002<\/p>\n \u3042\u3068\u306f\u597d\u304d\u306a\u3068\u3053\u308d\u306bMarkdownEditor\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u5dee\u3057\u8fbc\u3080\u3060\u3051\u3067\u3059\u3002<\/p>\n XSS\u5bfe\u7b56\u90e8\u5206\u3092\u9664\u304f\u3068\u3001\u5c0e\u5165\u306e\u624b\u9593\u81ea\u4f53\u306fMavonEditor\u3068\u307b\u3068\u3093\u3069\u5dee\u306f\u3042\u308a\u307e\u305b\u3093\u3067\u3057\u305f\u3002<\/p>\n MavonEditor\u3067\u306f\u3067\u304d\u306a\u304b\u3063\u305fPreview\u7528\u306eHTML\u306b\u5bfe\u3057\u3066\u30b5\u30cb\u30bf\u30a4\u30ba\u3092\u884c\u3046\u305f\u3081\u306e EasyMDE\u306fMavonEditor\u3068\u9055\u3063\u3066HTML\u306b\u5909\u63db\u3057\u305f\u5024\u3092\u53d7\u3051\u53d6\u308b\u3053\u3068\u306f\u3067\u304d\u306a\u3044\u306e\u3067\u3001save\u30dc\u30bf\u30f3\u3092\u7528\u610f\u3057\u3066\u3001\u30dc\u30bf\u30f3\u30af\u30ea\u30c3\u30af\u6642\u306b\u3001 EasyMDE\u306f\u30d7\u30ec\u30d3\u30e5\u30fc\u6642\u306eXSS\u5bfe\u7b56\u3092\u3061\u3083\u3093\u3068\u3067\u304d\u308b\u306e\u3067\u3001\u5b89\u5fc3\u3057\u3066\u4f7f\u3048\u307e\u3059\u3002markdown editor\u3068\u3057\u3066\u306e\u6a5f\u80fd\u3082MavonEditor\u3068\u905c\u8272\u306a\u3044\u306e\u3067\u3001\u3053\u3061\u3089\u3092\u63a1\u7528\u3059\u308b\u3053\u3068\u3057\u307e\u3057\u305f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":" vue + typescript\u3067\u4f5c\u3063\u3066\u3044\u308b\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u30a2\u30d7\u30ea\u306bmarkdown editor\u3092\u5c0e\u5165\u3057\u305f\u306e\u3067\u5c11\u3057\u7d39\u4ecb\u3057\u307e\u3059\u3002 XSS\u5bfe\u7b56\u3092\u3061\u3083\u3093\u3068\u3067\u304d\u308b\u304b\u3068\u3044\u3046\u70b9\u306b\u7740\u76ee\u3057\u3064\u3064\u3001mavonEditor\u3068EasyMDE\u3092\u8a66\u3057\u3066\u6700\u7d42\u7684\u306bEasyMDE\u306e\u65b9\u3092\u63a1\u7528\u3057\u307e\u3057\u305f\u3002 mavonEditor 2020\u5e746\u6708\u6642\u70b9\u3067star\u6570\u30823.9k\u3042\u308a\u5b9f\u7e3e\u5341\u5206\u307d\u304b\u3063\u305f\u306e\u3067\u307e\u305a\u306f\u3053\u308c\u3092\u8a66\u3057\u307e\u3057\u305f\u3002 \u5c0e\u5165\u624b\u9806 \u3053\u3061\u3089\u3092\u30d9\u30fc\u30b9\u306b\u3084\u3063\u3066\u3044\u304f\u308f\u3051\u3067\u3059\u304c\u3001typescript\uff0b\u958b\u767a\u6642\u306fnode_modules\u30fb\u672c\u756a\u306fCDN\u3068\u3044\u3046\u524d\u63d0\u3067\u5c0e\u5165\u624b\u9806\u3092\u8a18\u8f09\u3057\u3066\u304a\u304d\u307e\u3059\u3002 \u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3001 npm install mavon-editor –save-dev mavonEditor.ts\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8a18\u8ff0\u3057\u307e\u3059\u3002css\u306fCDN\u304b\u3089\u8aad\u307f\u8fbc\u3080\u4e88\u5b9a\u306a\u306e\u3067\u3053\u3053\u3067\u306fimport\u3057\u307e\u305b\u3093\u3002 import Vue from &# <\/span>Continue Reading<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[25,21],"tags":[],"_links":{"self":[{"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/posts\/246"}],"collection":[{"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/comments?post=246"}],"version-history":[{"count":1,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/posts\/246\/revisions"}],"predecessor-version":[{"id":249,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/posts\/246\/revisions\/249"}],"wp:attachment":[{"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/media?parent=246"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/categories?post=246"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/tags?post=246"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}
\nXSS\u5bfe\u7b56\u3092\u3061\u3083\u3093\u3068\u3067\u304d\u308b\u304b\u3068\u3044\u3046\u70b9\u306b\u7740\u76ee\u3057\u3064\u3064\u3001mavonEditor<\/a>\u3068EasyMDE<\/a>\u3092\u8a66\u3057\u3066\u6700\u7d42\u7684\u306bEasyMDE\u306e\u65b9\u3092\u63a1\u7528\u3057\u307e\u3057\u305f\u3002
\n<\/p>\nmavonEditor<\/h2>\n
\u5c0e\u5165\u624b\u9806<\/h3>\n
npm install mavon-editor --save-dev<\/code><\/pre>\n
mavonEditor.ts<\/code>\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8a18\u8ff0\u3057\u307e\u3059\u3002css\u306fCDN\u304b\u3089\u8aad\u307f\u8fbc\u3080\u4e88\u5b9a\u306a\u306e\u3067\u3053\u3053\u3067\u306fimport\u3057\u307e\u305b\u3093\u3002<\/p>\n
import Vue from 'vue'\nimport mavonEditor from 'mavon-editor'\n\nVue.use(mavonEditor)<\/code><\/pre>\n
app.ts<\/code>\u3067\u306f\u3053\u306e
mavonEditor.ts<\/code>\u3092\u8aad\u307f\u8fbc\u3093\u3067
new Vue()<\/code>\u3057\u307e\u3059\u3002\u76f4\u63a5\u95a2\u4fc2\u306a\u3044import\u6587\u306a\u3069\u306f\u7701\u7565\u3057\u3066\u307e\u3059\u3002<\/p>\n
import '..\/plugins\/mavonEditor'\n\nnew Vue({\n render: (h: CreateElement): VNode => h(App),\n}).$mount('#app')<\/code><\/pre>\n
webpack.config.js<\/code>\u306bmavon-editor\u306f\u5916\u90e8\u304b\u3089\u8aad\u307f\u8fbc\u3080\u8a2d\u5b9a\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n
externals: {\n 'mavon-editor': 'MavonEditor'\n }<\/code><\/pre>\n
<html lang="en">\n <head>\n <link href="https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/github-markdown-css\/2.9.0\/github-markdown.min.css" rel="stylesheet">\n <\/head>\n <body>\n <script defer src="https:\/\/unpkg.com\/mavon-editor@2.9.0\/dist\/mavon-editor.js"><\/script>\n <script defer src="app.js"><\/script>\n <\/body>\n<\/html><\/code><\/pre>\n
\n\u5b9f\u969b\u306b\u4f7f\u3046\u3068\u304d\u306f\u3001@save\u30a4\u30d9\u30f3\u30c8\u3067\u5165\u529b\u6587\u5b57\u5217\u3084HTML\u3092\u53d6\u5f97\u3057\u3066\u3001\u3069\u3053\u304b\u306b\u4fdd\u5b58\u3057\u305f\u308aemit\u3092\u4f7f\u3063\u3066\u89aa\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u95a2\u6570\u3092\u547c\u3073\u51fa\u3057\u305f\u308a\u306a\u3069\u306e\u5b9f\u88c5\u304c\u5fc5\u8981\u3067\u3059\u3002<\/p>\n<template>\n <div>\n <mavon-editor\n v-model="body"\n :toolbars="toolbarsOption"\n language="en"\n \/>\n <\/div>\n<\/template>\n\nimport { Component, Prop, Vue } from 'vue-property-decorator'\n\n@Component\nexport default class MarkdownEditor extends Vue {\n @Prop() private body!: string\n private toolbarsOption = {\n undo: true,\n redo: true,\n bold: true,\n underline: true,\n \/\/ \u3053\u3053\u306b\u30c4\u30fc\u30eb\u30d0\u30fc\u306b\u8868\u793a\u3057\u305f\u3044\u30a2\u30a4\u30b3\u30f3\u3092\u5217\u6319\n }\n}\n<\/script><\/code><\/pre>\n
<template>\n <div>\n <MarkdownEditor :body="body" \/>\n <\/div>\n<\/template>\n\n<script lang="ts">\nimport MarkdownEditor from '..\/components\/MarkdownEditor.vue'\n@Component({\n components: { MarkdownEditor },\n})\nexport default class Hoge extends Vue {\n private body = ''\n<\/script><\/code><\/pre>\n
XSS\u5bfe\u7b56<\/h3>\n
npm install<\/code>\u3057\u305f\u969b\u306b
found 1 high severity vulnerability<\/code>\u3068\u8a00\u308f\u308c\u307e\u3059\u3002
\nnpm audit<\/code>\u3067\u8a73\u7d30\u3092\u78ba\u8a8d\u3059\u308b\u3068
Cross-Site Scripting<\/code>\u306e\u8106\u5f31\u6027\u304c\u5831\u544a\u3055\u308c\u3066\u3044\u308b\u3088\u3046\u3067\u3059\u3002<\/p>\n
\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502 High \u2502 Cross-Site Scripting \u2502\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n\u2502 Package \u2502 mavon-editor \u2502\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n\u2502 Patched in \u2502 No patch available \u2502\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n\u2502 Dependency of \u2502 mavon-editor [dev] \u2502\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n\u2502 Path \u2502 mavon-editor \u2502\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n\u2502 More info \u2502 https:\/\/npmjs.com\/advisories\/1169 \u2502\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518<\/code><\/pre>\n
<img onerror=alert() src=1><\/code>\u3092\u8cbc\u308a\u4ed8\u3051\u3066\u307f\u308b\u3068\u898b\u4e8b\u306bscript\u304c\u5b9f\u884c\u3055\u308c\u307e\u3059\u3002\u3053\u308c\u306f\u5bfe\u7b56\u304c\u5fc5\u8981\u3060\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u4e8c\u3064\u8003\u3048\u307e\u3057\u305f\u3002<\/p>\n
mavonEditor\u304c\u63d0\u4f9b\u3057\u3066\u3044\u308bxss-options\u3092\u4f7f\u3046<\/h4>\n
<mavon-editor xss-options="{}" \/><\/code><\/pre>\n
<IMG SRC=\/ onerror="alert(String.fromCharCode(88,83,83))"><\/img>\n<img src="\/" =_=" title="onerror='prompt(1)'"><\/code><\/pre>\n
\nmavonEditor\u306f\u5165\u529b\u5024\u306b\u5bfe\u3057\u3066\u30b5\u30cb\u30bf\u30a4\u30ba\u3092\u3057\u3066\u5165\u529b\u5024\u3092\u7f6e\u304d\u63db\u3048\u3066\u3057\u307e\u3046<\/u>\u305f\u3081\u3001\u5165\u529b\u3057\u305f\u305d\u3070\u304b\u3089\u5165\u529b\u5024\u304c\u5909\u63db\u3055\u308c\u308b\u3068\u3044\u3046\u8b0e\u52d5\u4f5c\u304c\u767a\u751f\u3057\u3066\u3057\u307e\u3044\u307e\u3059\u3002
\n\u305f\u3068\u3048\u3070<<\/code>\u3092\u5165\u529b\u3057\u3088\u3046\u3068\u3059\u308b\u3068
<<\/code>\u304c\u5165\u529b\u3055\u308c\u3066\u3057\u307e\u3044\u307e\u3059\u3002\u4e00\u822c\u30e6\u30fc\u30b6\u304b\u3089\u898b\u305f\u3089\u30d0\u30b0\u3068\u53d6\u3089\u308c\u305d\u3046\u3067\u3059\u3002\u3002<\/p>\n
\n\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306e\u3053\u306e\u3078\u3093<\/a>\u3092\u898b\u3066\u3082\u3001\u5165\u529b\u5024\u305d\u306e\u3082\u306e\u3092\u66f8\u304d\u63db\u3048\u3066\u3057\u307e\u3046\u3088\u3046\u3067\u3059\uff08\u6d99\uff09<\/p>\n
\n\u3068\u306f\u3044\u3048\u3001\u3053\u306e\u30b3\u30df\u30c3\u30c8<\/a>\u3092\u307f\u308b\u3068xss-options\u306e\u5b9f\u88c5\u5909\u66f4\u306f2020\u5e744\u6708\u306b\u5165\u3063\u305f\u3070\u304b\u308a\u306e\u3088\u3046\u306a\u306e\u3067\u3001\u4eca\u5f8c\u6539\u5584\u3055\u308c\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002<\/p>\nxss-options\u3092\u4f7f\u308f\u306a\u3044\u3067\u3001\u81ea\u524d\u3067\u3069\u3046\u306b\u304b\u3059\u308b<\/h4>\n
\n\u306a\u306e\u3067\u3001\u30d7\u30ec\u30d3\u30e5\u30fc\u3092OFF\u306b\u3059\u308b\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u63a2\u3057\u305f\u306e\u3067\u3059\u304ctoolbar\u304b\u3089preview\u30a2\u30a4\u30b3\u30f3\u3092\u6d88\u3057\u305f\u3060\u3051\u3067\u306f\u7279\u306b\u52d5\u4f5c\u3082\u5909\u308f\u3089\u305a\u3001\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306e\u3053\u306e\u3078\u3093<\/a>\u304b\u3089\u305f\u3069\u3063\u3066\u3044\u3063\u3066\u3082\u3001\u30d7\u30ec\u30d3\u30e5\u30fc\u7528\u306eHTML\u63cf\u753b\u3092\u6b62\u3081\u308b\u3053\u3068\u306f\u3067\u304d\u305d\u3046\u306b\u3042\u308a\u307e\u305b\u3093\u3002\u307e\u305f\u3001\u30d7\u30ec\u30d3\u30e5\u30fc\u7528\u306eHTML\u306e\u5185\u5bb9\u3092\u5909\u66f4\u3059\u308b\u95a2\u6570\u3092\u5b9a\u7fa9\u3059\u308b\u305f\u3081\u306e\u30d5\u30c3\u30af\u3082\u306a\u3055\u305d\u3046\u3067\u3059\u3002<\/p>\n\u7d50\u8ad6<\/h3>\n
EasyMDE<\/h2>\n
\n\u3082\u3046\u5c11\u3057\u63a2\u3057\u3066\u3044\u308b\u3068\u3001SimpleMDE\u3092fork\u3057\u305fEasyMDE<\/a>\u3092\u767a\u898b\u3057\u307e\u3057\u305f\u3002\u3053\u3061\u3089\u306fstar\u6570\u3053\u305d653\u3068\u5c11\u306a\u3044\u3067\u3059\u304c\u3001\u30ac\u30f3\u30ac\u30f3\u958b\u767a\u304c\u9032\u3093\u3067\u308b\u306e\u304c\u826f\u3044\u3067\u3059\u3002\u6a5f\u80fd\u3082SimpleMDE\u3092fork\u3057\u3066\u3044\u308b\u3060\u3051\u3042\u3063\u3066\u554f\u984c\u306a\u3055\u305d\u3046\u306a\u306e\u3067\u3001\u3053\u3061\u3089\u3092\u8a66\u3057\u3066\u307f\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n\u5c0e\u5165\u624b\u9806<\/h3>\n
npm install easymde --save-dev\n\/\/ \u30b5\u30cb\u30bf\u30a4\u30ba\u7528\nnpm install dompurify --save-dev\nnpm install @dompurify\/marked --save-dev\n\/\/ HTML\u5909\u63db\u7528\nnpm install marked --save-dev\nnpm install @types\/marked --save-dev<\/code><\/pre>\n
webpack.config.js<\/code>\u306beasymde\u306f\u5916\u90e8\u304b\u3089\u8aad\u307f\u8fbc\u3080\u3088\u3046\u8a2d\u5b9a\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n
externals: {\n easymde: 'EasyMDE',\n DOMPurify: 'DOMPurify',\n marked: 'marked'\n }<\/code><\/pre>\n
\nmarkdown\u7528\u306eCSS\u306fgithub\u306e\u306e\u3082\u306e\u3092\u5229\u7528\u3055\u305b\u3066\u3044\u305f\u3060\u304f\u3053\u3068\u306b\u3057\u307e\u3059\u3002<\/p>\n<html lang="en">\n <head>\n <link rel="stylesheet" href="https:\/\/unpkg.com\/easymde\/dist\/easymde.min.css">\n <link rel="stylesheet" href="https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/github-markdown-css\/4.0.0\/github-markdown.min.css">\n <\/head>\n <body>\n <script defer src="https:\/\/unpkg.com\/easymde\/dist\/easymde.min.js"><\/script>\n <script defer src="https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/dompurify\/2.0.11\/purify.min.js"><\/script><!-- \u30b5\u30cb\u30bf\u30a4\u30ba -->\n <script defer src="https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/marked\/1.1.0\/marked.min.js"><\/script><!-- HTML\u5909\u63db -->\n <script defer src="app.js"><\/script>\n <\/body>\n<\/html><\/code><\/pre>\n
tsconfig.json<\/code>\u3067
"allowSyntheticDefaultImports": true<\/code>\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002 <\/p>\n
{\n "compilerOptions": {\n "allowSyntheticDefaultImports": true,\n }\n}<\/code><\/pre>\n
\n
<template>\n <div>\n <textarea id="easymde-area" \/>\n <button @click="handleSaveBtn">save<\/button>\n <\/div>\n<\/template>\n\nimport { Component, Prop, Vue } from 'vue-property-decorator'\nimport EasyMDE from 'easymde'\nimport DOMPurify from 'DOMPurify'\nimport * as marked from 'marked'\n\n@Component\nexport default class MarkdownEditor extends Vue {\n @Prop() private body!: string\n private html = ''\n private mde: EasyMDE | null = null\n\n private mounted(): void {\n const target: HTMLElement | null = this.$el.querySelector(\n 'textarea#easymde-area'\n )\n if (target !== null) {\n const config: EasyMDE.Options = {\n element: target,\n initialValue: this.body,\n autofocus: true,\n spellChecker: false,\n previewClass: ['editor-preview', 'markdown-body'],\n renderingConfig: {\n singleLineBreaks: true,\n codeSyntaxHighlighting: false,\n },\n toolbar: [\n 'bold',\n 'italic',\n 'strikethrough',\n 'heading',\n 'code',\n 'quote',\n 'unordered-list',\n 'ordered-list',\n 'table',\n 'horizontal-rule',\n 'preview',\n ],\n renderingConfig: {\n sanitizerFunction: (renderedHTML: string): string => {\n return this.sanitizeHtml(renderedHTML)\n },\n },\n }\n this.mde = new EasyMDE(config)\n }\n }\n\n private sanitizeHtml(html: string): string {\n const sanitizedHtml: string = DOMPurify.sanitize(html, {\n ALLOWED_TAGS: [\n 'b',\n 'li',\n 'ol',\n 'ul',\n 'p',\n 'strong',\n 'em',\n 'del',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'pre',\n 'code',\n 'blockquote',\n 'table',\n 'thead',\n 'tbody',\n 'tr',\n 'th',\n 'td',\n 'hr',\n ],\n })\n return sanitizedHtml\n }\n\n handleSaveBtn(): void {\n if (this.mde !== null) {\n this.body = marked(this.mde.value())\n this.html = this.sanitizeHtml(marked(this.body))\n }\n }\n}\n<\/script><\/code><\/pre>\n
\n
mounted()<\/code>\u3067easyMDE\u3092\u521d\u671f\u5316<\/li>\n
spellChecker: false<\/code>\u3092\u6307\u5b9a\u3057\u3066spell check\u3092\u7121\u52b9\u5316<\/li>\n
previewClass<\/code>\u306b\u306f\u3001easyMDE\u306e
editor-preview<\/code> class\u3068\u3001github\u306e
markdown-body<\/code> class\u306e\u4e21\u65b9\u3092\u6307\u5b9a\uff08
editor-preview<\/code>\u3092\u6307\u5b9a\u3057\u306a\u3044\u3068\u8868\u793a\u304c\u304a\u304b\u3057\u304f\u306a\u308b\uff09<\/li>\n<\/ul>\n
<template>\n <div>\n <MarkdownEditor :body="body" \/>\n <\/div>\n<\/template>\n\n<script lang="ts">\nimport MarkdownEditor from '..\/components\/MarkdownEditor.vue'\n@Component({\n components: { MarkdownEditor },\n})\nexport default class Hoge extends Vue {\n private body = ''\n<\/script><\/code><\/pre>\n
XSS\u5bfe\u7b56<\/h3>\n
sanitizerFunction<\/code>\u3068\u3044\u3046\u30d5\u30c3\u30af\u304c\u7528\u610f\u3055\u308c\u3066\u3044\u307e\u3059\u306e\u3067\u305d\u306e\u4e2d\u3067\u30b5\u30cb\u30bf\u30a4\u30ba\u3092\u884c\u3046\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002
\n\u30b5\u30cb\u30bf\u30a4\u30ba\u3092\u81ea\u524d\u3067\u5b9f\u88c5\u3059\u308b\u306e\u306f\u5927\u5909\u306a\u306e\u3067\u3001\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u5c0e\u5165\u3057\u307e\u3057\u305f\u3002js-xss<\/a>\u3068DOMPurify<\/a>\u3092\u691c\u8a0e\u3057\u305f\u306e\u3067\u3059\u304c\u3001js-xss\u306e\u65b9\u306f\u3001XSS\u306e\u30c1\u30fc\u30c8\u30b7\u30fc\u30c8\u306e\u5185\u5bb9\u30672\u4ef6\u307b\u3069\u30a8\u30e9\u30fc\u304c\u51fa\u305f\u306e\u3067\u3001DOMPurify\u3092\u63a1\u7528\u3057\u3066\u3044\u307e\u3059\u3002
\n\u5358\u7d14\u306bDOMPurify.sanitize()<\/code>\u3059\u308b\u3068\u3001\u5168\u3066\u306e\u30bf\u30b0\u304c\u30b5\u30cb\u30bf\u30a4\u30ba\u3055\u308c\u3066\u3001\u30de\u30fc\u30af\u30c0\u30a6\u30f3\u3068\u3057\u3066\u306e\u6a5f\u80fd\u3092\u679c\u305f\u3055\u306a\u304f\u306a\u3063\u3066\u3057\u307e\u3046\u305f\u3081\u3001XSS\u306e\u5bfe\u8c61\u306b\u306a\u3089\u306a\u3044\u5b89\u5168\u306aHTML\u30bf\u30b0\u306f\u30b5\u30cb\u30bf\u30a4\u30ba\u5bfe\u8c61\u304b\u3089\u9664\u5916\u3059\u308b\u3068\u3068\u3082\u306b\u3001\u30c4\u30fc\u30eb\u30d0\u30fc\u306b\u3082\u30a2\u30a4\u30b3\u30f3\u3092\u8868\u793a\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3057\u305f\u3002\uff08
<a><\/code>\u3084
<img><\/code>\u306fXSS\u306e\u5bfe\u8c61\u306b\u306a\u308a\u3046\u308b\u306e\u3067\u3001\u9664\u5916\u3057\u3066\u3044\u307e\u3059\uff09
\n\u5b9f\u88c5\u5f8c\u3001\u30c1\u30fc\u30c8\u30b7\u30fc\u30c8<\/a>\u306e\u5185\u5bb9\u3092\u8cbc\u308a\u4ed8\u3051\u3066\u30d7\u30ec\u30d3\u30e5\u30fc\u3057\u3066\u3082\u30011\u4ef6\u3082\u30a8\u30e9\u30fc\u306f\u767a\u751f\u3057\u307e\u305b\u3093\u3067\u3057\u305f\u3002<\/p>\nHTML\u5909\u63db<\/h3>\n
marked<\/code>\u3092\u4f7f\u3063\u3066HTML\u306b\u5909\u63db\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3057\u305f\u3002\u3053\u306e\u969b\u3001\u30d7\u30ec\u30d3\u30e5\u30fc\u6642\u3068\u540c\u69d8\u306b\u30b5\u30cb\u30bf\u30a4\u30ba\u3092\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n
\u7d50\u8ad6<\/h2>\n