Skip to content

Commit 13f36b0

Browse files
committed
Use sanitize-html instead of string for security reason.
See jprichardson/string.js#212
1 parent 26e9552 commit 13f36b0

File tree

3 files changed

+213
-17
lines changed

3 files changed

+213
-17
lines changed

lib/helper.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const helper = exports
44
const debug = require('debug')('pushserver:helper')
55
const he = require('he')
66
const _ = require('lodash')
7-
const string = require('string')
7+
const sanitizeHtml = require('sanitize-html')
88
const url = require('url')
99

1010
helper.prepareApnMessage = function (originalMessage) {
@@ -160,7 +160,11 @@ helper.prepareGcmSenderOptions = function (packageId, config) {
160160
}
161161

162162
helper.prepareNotificationHtml = function (html) {
163-
const trimmed = string(html).stripTags().trim().s
163+
const stripped = sanitizeHtml(html, {
164+
allowedTags: [],
165+
allowedAttributes: []
166+
})
167+
const trimmed = stripped.trim()
164168
const decoded = he.decode(trimmed)
165169

166170
return decoded

npm-shrinkwrap.json

Lines changed: 206 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"node-gcm": "^1.0.2",
1919
"pug": "^2.0.0-alpha6",
2020
"request": "^2.87.0",
21-
"string": "~3.3.1",
21+
"sanitize-html": "^1.19.0",
2222
"wns": "~0.5.3"
2323
},
2424
"devDependencies": {

0 commit comments

Comments
 (0)