You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
other (Please do not submit support requests here (see above))
Current behavior:
function defaultHttpResponseTransform(data, headers) {
if (isString(data)) {
// Strip json vulnerability protection prefix and trim whitespace
var tempData = data.replace(JSON_PROTECTION_PREFIX, '').trim();
if (tempData) {
var contentType = headers('Content-Type');
if ((contentType && (contentType.indexOf(APPLICATION_JSON) === 0)) || isJsonLike(tempData)) {
try {
data = fromJson(tempData);
} catch (e) {
throw $httpMinErr('baddata', 'Data must be a valid JSON object. Received: "{0}". ' +
'Parse error: "{1}"', data, e);
}
}
}
}
return data;
}
In defaultHttpResponseTransform() if the response data passes the isJsonLike() function, the function tries to transform the data using fromJson(). This may fail if the data isn't actually Json. If a server sends contentType "text/plain" with data "{a}" or "[a]" for example, these will result in angular throwing an error.
Expected / new behavior:
If the contentType is "text/plain", the defaultHttpResponseTransform should return the data without trying to change it.