From 23573f03e74c1327dd7aa54dc7c519c7caf41c13 Mon Sep 17 00:00:00 2001 From: Carl Date: Thu, 27 Jul 2017 15:09:44 +0200 Subject: [PATCH 1/5] fix($http): add check for functions in request Avoid that functions in `params` object (like getter or setter) will be encoded in the url. --- src/ng/http.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ng/http.js b/src/ng/http.js index f2c597c452a7..a4e2094ab203 100644 --- a/src/ng/http.js +++ b/src/ng/http.js @@ -41,7 +41,7 @@ function $HttpParamSerializerProvider() { if (!params) return ''; var parts = []; forEachSorted(params, function(value, key) { - if (value === null || isUndefined(value)) return; + if (value === null || isUndefined(value) || isFunction(value)) return; if (isArray(value)) { forEach(value, function(v) { parts.push(encodeUriQuery(key) + '=' + encodeUriQuery(serializeValue(v))); From 4930476ef7d316b98a5a4a261a3041b0fac05a72 Mon Sep 17 00:00:00 2001 From: Carl Date: Fri, 28 Jul 2017 17:39:21 +0200 Subject: [PATCH 2/5] test($http): default serializer default serializer should not serialize functions --- test/ng/httpSpec.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/ng/httpSpec.js b/test/ng/httpSpec.js index 5b21ee15a56b..dc17a207681f 100644 --- a/test/ng/httpSpec.js +++ b/test/ng/httpSpec.js @@ -2345,6 +2345,10 @@ describe('$http param serializers', function() { expect(jqrSer({someDate: new Date('2014-07-15T17:30:00.000Z')})).toEqual('someDate=2014-07-15T17:30:00.000Z'); }); + it('should NOT serialize functions', function() { + expect(defSer({foo: 'foov', bar: function() {}})).toEqual('bar=barv'); + }); + }); describe('default array serialization', function() { From 2d8b4f15da604a351d834df6928eb244b9a9f7f0 Mon Sep 17 00:00:00 2001 From: Carl Date: Fri, 28 Jul 2017 17:50:42 +0200 Subject: [PATCH 3/5] test($http): default serializer default serializer should not serialize functions --- test/ng/httpSpec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/ng/httpSpec.js b/test/ng/httpSpec.js index dc17a207681f..c7b1f9c797d5 100644 --- a/test/ng/httpSpec.js +++ b/test/ng/httpSpec.js @@ -2346,7 +2346,7 @@ describe('$http param serializers', function() { }); it('should NOT serialize functions', function() { - expect(defSer({foo: 'foov', bar: function() {}})).toEqual('bar=barv'); + expect(defSer({foo: 'foov', bar: function() {}})).toEqual('foo=foov'); }); }); From ee57d5299c6b03f1977f660c07732fba9a80dfeb Mon Sep 17 00:00:00 2001 From: Carl Date: Sun, 30 Jul 2017 10:24:39 +0200 Subject: [PATCH 4/5] test($http): avoid function serilization default serialization should not serialize functions --- test/ng/httpSpec.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/ng/httpSpec.js b/test/ng/httpSpec.js index c7b1f9c797d5..85c4feda32da 100644 --- a/test/ng/httpSpec.js +++ b/test/ng/httpSpec.js @@ -2345,9 +2345,7 @@ describe('$http param serializers', function() { expect(jqrSer({someDate: new Date('2014-07-15T17:30:00.000Z')})).toEqual('someDate=2014-07-15T17:30:00.000Z'); }); - it('should NOT serialize functions', function() { - expect(defSer({foo: 'foov', bar: function() {}})).toEqual('foo=foov'); - }); + }); @@ -2356,6 +2354,10 @@ describe('$http param serializers', function() { it('should serialize arrays by repeating param name', function() { expect(defSer({a: 'b', foo: ['bar', 'baz']})).toEqual('a=b&foo=bar&foo=baz'); }); + + it('should NOT serialize functions', function() { + expect(defSer({foo: 'foov', bar: function() {}})).toEqual('foo=foov'); + }); }); describe('jquery array and objects serialization', function() { From ca6e0e04cae98b074390277031bcda6bd1e0bd5a Mon Sep 17 00:00:00 2001 From: Carl Date: Sun, 30 Jul 2017 10:26:32 +0200 Subject: [PATCH 5/5] test($http): default param serialization functions should NOT be serialized --- test/ng/httpSpec.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/test/ng/httpSpec.js b/test/ng/httpSpec.js index 85c4feda32da..7ed6993c4109 100644 --- a/test/ng/httpSpec.js +++ b/test/ng/httpSpec.js @@ -2344,9 +2344,6 @@ describe('$http param serializers', function() { expect(defSer({someDate: new Date('2014-07-15T17:30:00.000Z')})).toEqual('someDate=2014-07-15T17:30:00.000Z'); expect(jqrSer({someDate: new Date('2014-07-15T17:30:00.000Z')})).toEqual('someDate=2014-07-15T17:30:00.000Z'); }); - - - }); describe('default array serialization', function() { @@ -2354,7 +2351,7 @@ describe('$http param serializers', function() { it('should serialize arrays by repeating param name', function() { expect(defSer({a: 'b', foo: ['bar', 'baz']})).toEqual('a=b&foo=bar&foo=baz'); }); - + it('should NOT serialize functions', function() { expect(defSer({foo: 'foov', bar: function() {}})).toEqual('foo=foov'); });