Skip to content

Commit

Permalink
Use sanitize-html instead of string for security reason.
Browse files Browse the repository at this point in the history
  • Loading branch information
daohoangson committed Sep 25, 2018
1 parent 26e9552 commit 13f36b0
Show file tree
Hide file tree
Showing 3 changed files with 213 additions and 17 deletions.
8 changes: 6 additions & 2 deletions lib/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const helper = exports
const debug = require('debug')('pushserver:helper')
const he = require('he')
const _ = require('lodash')
const string = require('string')
const sanitizeHtml = require('sanitize-html')
const url = require('url')

helper.prepareApnMessage = function (originalMessage) {
Expand Down Expand Up @@ -160,7 +160,11 @@ helper.prepareGcmSenderOptions = function (packageId, config) {
}

helper.prepareNotificationHtml = function (html) {
const trimmed = string(html).stripTags().trim().s
const stripped = sanitizeHtml(html, {
allowedTags: [],
allowedAttributes: []
})
const trimmed = stripped.trim()
const decoded = he.decode(trimmed)

return decoded
Expand Down
220 changes: 206 additions & 14 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"node-gcm": "^1.0.2",
"pug": "^2.0.0-alpha6",
"request": "^2.87.0",
"string": "~3.3.1",
"sanitize-html": "^1.19.0",
"wns": "~0.5.3"
},
"devDependencies": {
Expand Down

0 comments on commit 13f36b0

Please sign in to comment.