From f3fd4dee985a37a6699ad2c78d58c36095678f3e Mon Sep 17 00:00:00 2001 From: Antoine Pultier Date: Tue, 2 Jun 2015 16:50:21 +0200 Subject: [PATCH] fix:$http:Silently fail when isJsonLike wrongly detects JSON isJsonLike can have false positives. Instead of crashing, the defaultHttpHandler should return the string. --- src/ng/http.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ng/http.js b/src/ng/http.js index fdab62a776eb..5dd0d12a47e0 100644 --- a/src/ng/http.js +++ b/src/ng/http.js @@ -93,8 +93,12 @@ function defaultHttpResponseTransform(data, headers) { if (tempData) { var contentType = headers('Content-Type'); - if ((contentType && (contentType.indexOf(APPLICATION_JSON) === 0)) || isJsonLike(tempData)) { + if (contentType && (contentType.indexOf(APPLICATION_JSON) === 0)) { data = fromJson(tempData); + } else if (isJsonLike(tempData)) { + try { + data = fromJson(tempData); + } catch(e) {} } } }