summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2014-05-21 14:51:45 -0400
committerBernard Normier <bernard@zeroc.com>2014-05-21 14:51:45 -0400
commit178179830adb16adc56388bd66ebf0bc1a7f3fae (patch)
tree784a48e93c383105cc1f54de1af77534ea8fad8a /cpp
parentAdded missing .gitignore for C# IceDiscovery replication demo (diff)
downloadice-178179830adb16adc56388bd66ebf0bc1a7f3fae.tar.bz2
ice-178179830adb16adc56388bd66ebf0bc1a7f3fae.tar.xz
ice-178179830adb16adc56388bd66ebf0bc1a7f3fae.zip
Fixed bug ICE-5543: stringToIdentity bug with escaped escapes
Diffstat (limited to 'cpp')
-rw-r--r--cpp/src/Ice/Instance.cpp14
-rw-r--r--cpp/test/Ice/proxy/AllTests.cpp12
2 files changed, 24 insertions, 2 deletions
diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp
index aa9f8247e3b..23b4b9671cb 100644
--- a/cpp/src/Ice/Instance.cpp
+++ b/cpp/src/Ice/Instance.cpp
@@ -449,12 +449,22 @@ IceInternal::Instance::stringToIdentity(const string& s) const
Identity ident;
//
- // Find unescaped separator.
+ // Find unescaped separator; note that the string may contain an escaped
+ // backslash before the separator.
//
string::size_type slash = string::npos, pos = 0;
while((pos = s.find('/', pos)) != string::npos)
{
- if(pos == 0 || s[pos - 1] != '\\')
+ int escapes = 0;
+ while(static_cast<int>(pos)- escapes > 0 && s[pos - escapes - 1] == '\\')
+ {
+ escapes++;
+ }
+
+ //
+ // We ignore escaped escapes
+ //
+ if(escapes % 2 == 0)
{
if(slash == string::npos)
{
diff --git a/cpp/test/Ice/proxy/AllTests.cpp b/cpp/test/Ice/proxy/AllTests.cpp
index 32cad69153d..6778baef2b7 100644
--- a/cpp/test/Ice/proxy/AllTests.cpp
+++ b/cpp/test/Ice/proxy/AllTests.cpp
@@ -252,6 +252,18 @@ allTests(const Ice::CommunicatorPtr& communicator)
catch(const Ice::EndpointParseException&)
{
}
+
+ //
+ // Test for bug ICE-5543: escaped escapes in stringToIdentity
+ //
+ Ice::Identity id = { "test", ",X2QNUAzSBcJ_e$AV;E\\" };
+ Ice::Identity id2 = communicator->stringToIdentity(communicator->identityToString(id));
+ test(id == id2);
+
+ id = { "test", ",X2QNUAz\\SB\\/cJ_e$AV;E\\\\" };
+ id2 = communicator->stringToIdentity(communicator->identityToString(id));
+ test(id == id2);
+
cout << "ok" << endl;
cout << "testing propertyToProxy... " << flush;