diff options
author | Benoit Foucher <benoit@zeroc.com> | 2016-04-26 09:00:57 +0200 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2016-04-26 09:00:57 +0200 |
commit | c2ce37b7b0f6fc033cac4d52d460ee2f389d7737 (patch) | |
tree | dab204bc1dfd9298c7acb13b9493a210f8c4e978 /js | |
parent | Add jquery-cookie to bower dependency (diff) | |
download | ice-c2ce37b7b0f6fc033cac4d52d460ee2f389d7737.tar.bz2 ice-c2ce37b7b0f6fc033cac4d52d460ee2f389d7737.tar.xz ice-c2ce37b7b0f6fc033cac4d52d460ee2f389d7737.zip |
Fixed ICE-7115 - unmarshalling bug with optional parameters
Diffstat (limited to 'js')
-rw-r--r-- | js/src/Ice/AsyncResult.js | 4 | ||||
-rw-r--r-- | js/src/Ice/BasicStream.js | 23 | ||||
-rw-r--r-- | js/src/Ice/IncomingAsync.js | 3 | ||||
-rw-r--r-- | js/src/Ice/OutgoingAsync.js | 2 | ||||
-rw-r--r-- | js/test/Ice/optional/Client.js | 12 | ||||
-rw-r--r-- | js/test/Ice/optional/ClientPrivate.ice | 39 | ||||
-rw-r--r-- | js/test/Ice/optional/Test.ice | 4 | ||||
-rw-r--r-- | js/test/Ice/optionalBidir/AMDInitialI.js | 4 | ||||
-rw-r--r-- | js/test/Ice/optionalBidir/InitialI.js | 3 | ||||
-rw-r--r-- | js/test/Ice/optionalBidir/Test.ice | 4 | ||||
-rw-r--r-- | js/test/Ice/optionalBidir/TestAMD.ice | 4 |
11 files changed, 84 insertions, 18 deletions
diff --git a/js/src/Ice/AsyncResult.js b/js/src/Ice/AsyncResult.js index ee75db25e3a..0599e307584 100644 --- a/js/src/Ice/AsyncResult.js +++ b/js/src/Ice/AsyncResult.js @@ -38,7 +38,7 @@ var AsyncResult = Ice.Class(AsyncResultBase, { { return; } - + this._completed = completedFn; this._is = null; this._os = com !== null ? new BasicStream(this._instance, Protocol.currentProtocolEncoding) : null; @@ -148,7 +148,7 @@ var AsyncResult = Ice.Class(AsyncResultBase, { }, __readEmptyParams: function() { - this._is.skipEmptyEncaps(null); + this._is.skipEmptyEncaps(); }, __readParamEncaps: function() { diff --git a/js/src/Ice/BasicStream.js b/js/src/Ice/BasicStream.js index 86218149b8a..b00b2d9adfb 100644 --- a/js/src/Ice/BasicStream.js +++ b/js/src/Ice/BasicStream.js @@ -1952,29 +1952,34 @@ var BasicStream = Class({ this._readEncapsCache = curr; this._readEncapsCache.reset(); }, - skipEmptyEncaps: function(encoding) + skipEmptyEncaps: function() { - Debug.assert(encoding !== undefined); var sz = this.readInt(); - if(sz !== 6) + if(sz < 6) { throw new Ice.EncapsulationException(); } - - var pos = this._buf.position; - if(pos + 2 > this._buf.limit) + if(sz - 4 > this._buf.remaining) { throw new Ice.UnmarshalOutOfBoundsException(); } - if(encoding !== null) + var encoding = new Ice.EncodingVersion(); + encoding.__read(this); + if(encoding.equals(Ice.Encoding_1_0)) { - encoding.__read(this); + if(sz != 6) + { + throw new Ice.EncapsulationException(); + } } else { - this._buf.position = pos + 2; + // Skip the optional content of the encapsulation if we are expecting an + // empty encapsulation. + this._buf.position = this._buf.position + sz - 6; } + return encoding; }, endReadEncapsChecked: function() // Used by public stream API. { diff --git a/js/src/Ice/IncomingAsync.js b/js/src/Ice/IncomingAsync.js index 713d92d51fd..eee2a0121a6 100644 --- a/js/src/Ice/IncomingAsync.js +++ b/js/src/Ice/IncomingAsync.js @@ -577,8 +577,7 @@ var IncomingAsync = Ice.Class({ }, readEmptyParams: function() { - this._current.encoding = new Ice.EncodingVersion(); - this._is.skipEmptyEncaps(this._current.encoding); + this._current.encoding = this._is.skipEmptyEncaps(); }, readParamEncaps: function() { diff --git a/js/src/Ice/OutgoingAsync.js b/js/src/Ice/OutgoingAsync.js index 2b6214342de..e49c92fc0c7 100644 --- a/js/src/Ice/OutgoingAsync.js +++ b/js/src/Ice/OutgoingAsync.js @@ -491,7 +491,7 @@ var OutgoingAsync = Ice.Class(ProxyOutgoingAsyncBase, { }, __readEmptyParams: function() { - this._is.skipEmptyEncaps(null); + this._is.skipEmptyEncaps(); }, __readParamEncaps: function() { diff --git a/js/test/Ice/optional/Client.js b/js/test/Ice/optional/Client.js index f28a37e1fe9..02cb3340d76 100644 --- a/js/test/Ice/optional/Client.js +++ b/js/test/Ice/optional/Client.js @@ -11,6 +11,7 @@ { var Ice = require("ice").Ice; var Test = require("Test").Test; + var ClientPrivate = require("../optional/ClientPrivate").Test; var Promise = Ice.Promise; var ArrayUtil = Ice.ArrayUtil; @@ -355,7 +356,16 @@ test(g.gg2.a.equals(new Ice.Long(0, 10))); test(g.gg2Opt.a.equals(new Ice.Long(0, 20))); test(g.gg1.a == "gg1"); - + } + ).then( + function() + { + var init2 = ClientPrivate.Initial2Prx.uncheckedCast(initial) + return init2.opVoid(5, "test"); + } + ).then( + function() + { out.writeLine("ok"); out.write("testing marshaling of large containers with fixed size elements... "); var mc = new Test.MultiOptional(); diff --git a/js/test/Ice/optional/ClientPrivate.ice b/js/test/Ice/optional/ClientPrivate.ice new file mode 100644 index 00000000000..5dd08613b9a --- /dev/null +++ b/js/test/Ice/optional/ClientPrivate.ice @@ -0,0 +1,39 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#pragma once + +#include <Test.ice> + +module Test +{ + +// +// The server doesn't know this class. +// +class D extends B +{ + string ds; + optional(990) StringSeq seq; + optional(1000) A ao; +}; + +// +// This class is a hack that allows us to invoke the opClassAndUnknownOptional operation +// on the server and pass an optional argument. This isn't necessary in other language +// mappings where the public stream API is available. +// +class Initial2 +{ + void opClassAndUnknownOptional(A p, optional(1) Object o); + + void opVoid(optional(1) int a, optional(2) string v); +}; + +}; diff --git a/js/test/Ice/optional/Test.ice b/js/test/Ice/optional/Test.ice index 00d8381fc75..81d6d459690 100644 --- a/js/test/Ice/optional/Test.ice +++ b/js/test/Ice/optional/Test.ice @@ -301,9 +301,11 @@ class Initial void sendOptionalClass(bool req, optional(1) OneOptional o); void returnOptionalClass(bool req, out optional(1) OneOptional o); - + G opG(G g); + void opVoid(); + bool supportsRequiredParams(); bool supportsJavaSerializable(); diff --git a/js/test/Ice/optionalBidir/AMDInitialI.js b/js/test/Ice/optionalBidir/AMDInitialI.js index 74d9070bf98..332b2a562bf 100644 --- a/js/test/Ice/optionalBidir/AMDInitialI.js +++ b/js/test/Ice/optionalBidir/AMDInitialI.js @@ -359,6 +359,10 @@ { cb.ice_response(g); }, + opVoid_async: function(cb, current) + { + cb.ice_response(); + }, supportsRequiredParams_async: function(cb, current) { cb.ice_response(false); diff --git a/js/test/Ice/optionalBidir/InitialI.js b/js/test/Ice/optionalBidir/InitialI.js index 3884c32ef58..c50e3125a13 100644 --- a/js/test/Ice/optionalBidir/InitialI.js +++ b/js/test/Ice/optionalBidir/InitialI.js @@ -352,6 +352,9 @@ { return g; }, + opVoid: function() + { + }, returnOptionalClass: function(req, current) { return new Test.OneOptional(53); diff --git a/js/test/Ice/optionalBidir/Test.ice b/js/test/Ice/optionalBidir/Test.ice index 3e84af1c344..babee62c36e 100644 --- a/js/test/Ice/optionalBidir/Test.ice +++ b/js/test/Ice/optionalBidir/Test.ice @@ -301,9 +301,11 @@ class Initial void sendOptionalClass(bool req, optional(1) OneOptional o); void returnOptionalClass(bool req, out optional(1) OneOptional o); - + G opG(G g); + void opVoid(); + bool supportsRequiredParams(); bool supportsJavaSerializable(); diff --git a/js/test/Ice/optionalBidir/TestAMD.ice b/js/test/Ice/optionalBidir/TestAMD.ice index 05dd4d33001..54198e3045b 100644 --- a/js/test/Ice/optionalBidir/TestAMD.ice +++ b/js/test/Ice/optionalBidir/TestAMD.ice @@ -301,9 +301,11 @@ class G void sendOptionalClass(bool req, optional(1) OneOptional o); void returnOptionalClass(bool req, out optional(1) OneOptional o); - + G opG(G g); + void opVoid(); + bool supportsRequiredParams(); bool supportsJavaSerializable(); |