mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
fix($http): allow multiple json vulnerability prefixes
We strip out both: )]}', )]}'
This commit is contained in:
parent
fdcc2dbfd3
commit
fe633dd0cf
2 changed files with 12 additions and 1 deletions
|
|
@ -65,7 +65,8 @@ function $HttpProvider() {
|
|||
// transform in-coming reponse data
|
||||
transformResponse: function(data) {
|
||||
if (isString(data)) {
|
||||
if (/^\)\]\}',\n/.test(data)) data = data.substr(6);
|
||||
// strip json vulnerability protection prefix
|
||||
data = data.replace(/^\)\]\}',?\n/, '');
|
||||
if (/^\s*[\[\{]/.test(data) && /[\}\]]\s*$/.test(data))
|
||||
data = fromJson(data, true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -743,6 +743,16 @@ describe('$http', function() {
|
|||
expect(callback).toHaveBeenCalledOnce();
|
||||
expect(callback.mostRecentCall.args[0]).toEqual([1, 'abc', {foo:'bar'}]);
|
||||
});
|
||||
|
||||
|
||||
it('should deserialize json with security prefix ")]}\'"', function() {
|
||||
$httpBackend.expect('GET', '/url').respond(')]}\'\n\n[1, "abc", {"foo":"bar"}]');
|
||||
$http({method: 'GET', url: '/url'}).on('200', callback);
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(callback).toHaveBeenCalledOnce();
|
||||
expect(callback.mostRecentCall.args[0]).toEqual([1, 'abc', {foo:'bar'}]);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue