diff options
| author | Igor Minar | 2013-02-23 22:16:35 -0800 | 
|---|---|---|
| committer | Igor Minar | 2013-02-23 22:16:41 -0800 | 
| commit | 509ec745fdbb54b54672fbf8595a4958c16f2b53 (patch) | |
| tree | 0c27c342d0738e8f50457c983d09c557f478dcb0 /src/ng/httpBackend.js | |
| parent | d44ca19da7f4bd601d28822fb52d30fc006625f3 (diff) | |
| download | angular.js-509ec745fdbb54b54672fbf8595a4958c16f2b53.tar.bz2 | |
fix($httpBackend): prevent DOM err due to dereferencing .responseText
If responseType is defined and the request fails for one reason or another
the .response property returned falsy value which caused dereferencing of
.responseText. If the responseType was a blob or document then an error
was thrown.
To prevent this, I'm checking for responseType first and based on that
dereferencing .response or .responseText.
We need to keep on checking .responseText because that's the original XHR
response api that is still needed for IE8 and 9.
Closes #1922
Diffstat (limited to 'src/ng/httpBackend.js')
| -rw-r--r-- | src/ng/httpBackend.js | 8 | 
1 files changed, 6 insertions, 2 deletions
| diff --git a/src/ng/httpBackend.js b/src/ng/httpBackend.js index 5c967c6b..91ebe03d 100644 --- a/src/ng/httpBackend.js +++ b/src/ng/httpBackend.js @@ -87,8 +87,12 @@ function createHttpBackend($browser, XHR, $browserDefer, callbacks, rawDocument,            }            // end of the workaround. -          completeRequest(callback, status || xhr.status, xhr.response || xhr.responseText, -                          responseHeaders); +          // responseText is the old-school way of retrieving response (supported by IE8 & 9) +          // response and responseType properties were introduced in XHR Level2 spec (supported by IE10) +          completeRequest(callback, +              status || xhr.status, +              (xhr.responseType ? xhr.response : xhr.responseText), +              responseHeaders);          }        }; | 
