Skip to content

Commit a6d5ee2

Browse files
committed
fix binary data detection
exclude whitespace characters from binary specific characters and add unicode replacement character
1 parent 07f68e3 commit a6d5ee2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/util.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,8 @@ var util = {
223223
},
224224

225225
/**
226-
* Decide if data should be treated as binary based on the content
227-
* and content-type.
226+
* Decide if data should be treated as binary based on the content (presence of non-printable characters
227+
* or replacement character) and content-type.
228228
*
229229
* @param {string} content - The data
230230
* @param {string} mimeType - The data's content-type
@@ -233,7 +233,7 @@ var util = {
233233
*/
234234
shouldBeTreatedAsBinary (content, mimeType) {
235235
// eslint-disable-next-line no-control-regex
236-
return (mimeType && mimeType.match(/charset=binary/)) || /[\x00-\x1F]/.test(content);
236+
return (mimeType && mimeType.match(/charset=binary/)) || /[\x00-\x08\x0E-\x1F\uFFFD]/.test(content);
237237
},
238238

239239
/**

0 commit comments

Comments
 (0)