Skip to content

Commit f3de30c

Browse files
committed
fixing types for xml sanitizer
1 parent a0ed284 commit f3de30c

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

player/service/plugins/routes/lib/helpers.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,19 @@ module.exports = {
152152
},
153153

154154
/**
155-
* Checks the given XML content, returning false if the content
156-
* appears potentially malicious.
155+
* Attempts to sanitize the given content, throwing an error if the provided
156+
* content is neither a string nor a Buffer.
157+
*
157158
* @param {String|Buffer} xmlContent
158159
*/
159160
sanitizeXML: async(xmlContent) => {
160-
return xmlSanitizer(xmlContent);
161+
if (typeof xmlContent === "string")
162+
return xmlSanitizer(xmlContent);
163+
else if (Buffer.isBuffer(xmlContent))
164+
return xmlSanitizer(xmlContent.toString());
165+
else
166+
console.error("helpers.sanitizeXML requires either a string or a Buffer -- received: " + typeof xmlContent);
167+
168+
return undefined;
161169
}
162170
};

0 commit comments

Comments
 (0)