Browse Source

Fix #2011 (#2012)

* fix #2011

The isXml() method will return false if the Content-Type header is not set in the S3 response

* aws-s3: fix lint

Co-authored-by: Renée Kooi <renee@kooi.me>
Gerd R 5 years ago
parent
commit
72210adee7
1 changed files with 8 additions and 4 deletions
  1. 8 4
      packages/@uppy/aws-s3/src/index.js

+ 8 - 4
packages/@uppy/aws-s3/src/index.js

@@ -12,10 +12,14 @@ function resolveUrl (origin, link) {
 }
 
 function isXml (content, xhr) {
-  const contentType = (xhr.headers ? xhr.headers['content-type'] : xhr.getResponseHeader('Content-Type'))
-    // Get rid of mime parameters like charset=utf-8
-    .replace(/;.*$/, '')
-    .toLowerCase()
+  const rawContentType = (xhr.headers ? xhr.headers['content-type'] : xhr.getResponseHeader('Content-Type'))
+
+  if (rawContentType === null) {
+    return false
+  }
+
+  // Get rid of mime parameters like charset=utf-8
+  const contentType = rawContentType.replace(/;.*$/, '').toLowerCase()
   if (typeof contentType === 'string') {
     if (contentType === 'application/xml' || contentType === 'text/xml') {
       return true