Skip to content
This repository has been archived by the owner on Apr 12, 2023. It is now read-only.

Commit

Permalink
Fix buggy html
Browse files Browse the repository at this point in the history
  • Loading branch information
zcbenz committed Feb 28, 2019
1 parent 7aa55fb commit cd0e336
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 5 additions & 1 deletion lib/service/slack/message-parser.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const stringReplaceAsync = require('string-replace-async')
const sanitizeHtml = require('sanitize-html')

const emoji = require('./emoji.json')

Expand Down Expand Up @@ -125,7 +126,10 @@ function parseMarkdown(account, text) {
start = preIndex + 3
}
newText += runRules(account, text.substr(start).trimLeft())
return newText

// Our parser is buggy, and sometimes HTML passed from Slack is also bug, the
// easist way to fix this is to run sanitizeHtml.
return sanitizeHtml(newText, {allowedTags: false, allowedAttributes: false})
}

function slackMarkdownToHtmlSync(account, text) {
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,15 @@
"download-yue": "2.x",
"fetch-yode": "0.2.0",
"fs-extra": "5.0.0",
"gui": "0.5.3",
"gui": "0.6.3",
"keytar": "4.3.0",
"mini-signals": "1.1.1",
"opn": "5.3.0",
"readable-size": "0.2.0",
"sanitize-html": "1.20.0",
"string-replace-async": "1.2.1"
},
"devDependencies": {
"yackage": "0.2.8"
"yackage": "0.2.9"
}
}

0 comments on commit cd0e336

Please sign in to comment.