summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cpp/src/Glacier2Lib/SessionHelper.cpp12
-rw-r--r--cpp/src/Ice/CommunicatorI.cpp4
-rw-r--r--cpp/src/Ice/Incoming.cpp4
-rw-r--r--cpp/src/Ice/Instance.cpp115
-rw-r--r--cpp/src/Ice/Instance.h2
-rw-r--r--cpp/src/Ice/LocatorInfo.cpp12
-rw-r--r--cpp/src/Ice/ObjectAdapterI.cpp2
-rw-r--r--cpp/src/Ice/Reference.cpp2
-rw-r--r--cpp/src/Ice/ReferenceFactory.cpp2
-rw-r--r--cpp/src/Ice/ServantManager.cpp6
-rw-r--r--cpp/src/Ice/TraceUtil.cpp2
11 files changed, 145 insertions, 18 deletions
diff --git a/cpp/src/Glacier2Lib/SessionHelper.cpp b/cpp/src/Glacier2Lib/SessionHelper.cpp
index 623e0a2a869..7ce2d2c3eb9 100644
--- a/cpp/src/Glacier2Lib/SessionHelper.cpp
+++ b/cpp/src/Glacier2Lib/SessionHelper.cpp
@@ -1162,7 +1162,17 @@ string
Glacier2::SessionFactoryHelper::createProxyStr(const Ice::Identity& ident)
{
ostringstream os;
- os << "\"" << Ice::identityToString(ident) << "\":" << _protocol << " -p " << getPortInternal() << " -h \"" << _routerHost << "\"";
+ os << "\"";
+ //
+ // TODO replace with identityToString, we cannot use the Communicator::identityToString
+ // current implementation because we need to do that before the communicator has been
+ // initialized.
+ //
+ if(!ident.category.empty())
+ {
+ os << ident.category << "/";
+ }
+ os << ident.name << "\":" << _protocol << " -p " << getPortInternal() << " -h \"" << _routerHost << "\"";
if(_timeout > 0)
{
os << " -t " << _timeout;
diff --git a/cpp/src/Ice/CommunicatorI.cpp b/cpp/src/Ice/CommunicatorI.cpp
index 3232cf57e5d..985acb23aa9 100644
--- a/cpp/src/Ice/CommunicatorI.cpp
+++ b/cpp/src/Ice/CommunicatorI.cpp
@@ -83,13 +83,13 @@ Ice::CommunicatorI::proxyToProperty(const ObjectPrx& proxy, const string& proper
Identity
Ice::CommunicatorI::stringToIdentity(const string& s) const
{
- return Ice::stringToIdentity(s);
+ return _instance->stringToIdentity(s);
}
string
Ice::CommunicatorI::identityToString(const Identity& ident) const
{
- return Ice::identityToString(ident);
+ return _instance->identityToString(ident);
}
ObjectAdapterPtr
diff --git a/cpp/src/Ice/Incoming.cpp b/cpp/src/Ice/Incoming.cpp
index f0de7b3c8e8..8b7e8a33ea4 100644
--- a/cpp/src/Ice/Incoming.cpp
+++ b/cpp/src/Ice/Incoming.cpp
@@ -172,7 +172,7 @@ IceInternal::IncomingBase::__warning(const Exception& ex) const
Warning out(_os.instance()->initializationData().logger);
out << "dispatch exception: " << ex;
- out << "\nidentity: " << Ice::identityToString(_current.id);
+ out << "\nidentity: " << _os.instance()->identityToString(_current.id);
out << "\nfacet: " << IceUtilInternal::escapeString(_current.facet, "");
out << "\noperation: " << _current.operation;
@@ -193,7 +193,7 @@ IceInternal::IncomingBase::__warning(const string& msg) const
Warning out(_os.instance()->initializationData().logger);
out << "dispatch exception: " << msg;
- out << "\nidentity: " << Ice::identityToString(_current.id);
+ out << "\nidentity: " << _os.instance()->identityToString(_current.id);
out << "\nfacet: " << IceUtilInternal::escapeString(_current.facet, "");
out << "\noperation: " << _current.operation;
diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp
index 9639a28afa6..4b3590c01de 100644
--- a/cpp/src/Ice/Instance.cpp
+++ b/cpp/src/Ice/Instance.cpp
@@ -576,6 +576,121 @@ IceInternal::Instance::serverACM() const
return _serverACM;
}
+Identity
+IceInternal::Instance::stringToIdentity(const string& s) const
+{
+ //
+ // This method only accepts printable ascii. Since printable ascii is a subset
+ // of all narrow string encodings, it is not necessary to convert the string
+ // from the native string encoding. Any characters other than printable-ASCII
+ // will cause an IllegalArgumentException. Note that it can contain Unicode
+ // encoded in the escaped form which is the reason why we call fromUTF8 after
+ // unespcaping the printable ASCII string.
+ //
+
+ Identity ident;
+
+ //
+ // 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)
+ {
+ 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)
+ {
+ slash = pos;
+ }
+ else
+ {
+ //
+ // Extra unescaped slash found.
+ //
+ IdentityParseException ex(__FILE__, __LINE__);
+ ex.str = "unescaped backslash in identity `" + s + "'";
+ throw ex;
+ }
+ }
+ pos++;
+ }
+
+ if(slash == string::npos)
+ {
+ try
+ {
+ ident.name = IceUtilInternal::unescapeString(s, 0, s.size());
+ }
+ catch(const IceUtil::IllegalArgumentException& e)
+ {
+ IdentityParseException ex(__FILE__, __LINE__);
+ ex.str = "invalid identity name `" + s + "': " + e.reason();
+ throw ex;
+ }
+ }
+ else
+ {
+ try
+ {
+ ident.category = IceUtilInternal::unescapeString(s, 0, slash);
+ }
+ catch(const IceUtil::IllegalArgumentException& e)
+ {
+ IdentityParseException ex(__FILE__, __LINE__);
+ ex.str = "invalid category in identity `" + s + "': " + e.reason();
+ throw ex;
+ }
+ if(slash + 1 < s.size())
+ {
+ try
+ {
+ ident.name = IceUtilInternal::unescapeString(s, slash + 1, s.size());
+ }
+ catch(const IceUtil::IllegalArgumentException& e)
+ {
+ IdentityParseException ex(__FILE__, __LINE__);
+ ex.str = "invalid name in identity `" + s + "': " + e.reason();
+ throw ex;
+ }
+ }
+ }
+
+ ident.name = UTF8ToNative(ident.name, _stringConverter);
+ ident.category = UTF8ToNative(ident.category, _stringConverter);
+
+ return ident;
+}
+
+string
+IceInternal::Instance::identityToString(const Identity& ident) const
+{
+ //
+ // This method returns the stringified identity. The returned string only
+ // contains printable ascii. It can contain UTF8 in the escaped form.
+ //
+ string name = nativeToUTF8(ident.name, _stringConverter);
+ string category = nativeToUTF8(ident.category, _stringConverter);
+
+ if(category.empty())
+ {
+ return IceUtilInternal::escapeString(name, "/");
+ }
+ else
+ {
+ return IceUtilInternal::escapeString(category, "/") + '/' + IceUtilInternal::escapeString(name, "/");
+ }
+}
+
Ice::ObjectPrx
IceInternal::Instance::createAdmin(const ObjectAdapterPtr& adminAdapter, const Identity& adminIdentity)
{
diff --git a/cpp/src/Ice/Instance.h b/cpp/src/Ice/Instance.h
index 40b766d14ee..a6e9182b136 100644
--- a/cpp/src/Ice/Instance.h
+++ b/cpp/src/Ice/Instance.h
@@ -113,6 +113,8 @@ public:
bool collectObjects() const { return _collectObjects; }
const ACMConfig& clientACM() const;
const ACMConfig& serverACM() const;
+ Ice::Identity stringToIdentity(const std::string&) const;
+ std::string identityToString(const Ice::Identity&) const;
Ice::ObjectPrx createAdmin(const Ice::ObjectAdapterPtr&, const Ice::Identity&);
Ice::ObjectPrx getAdmin();
diff --git a/cpp/src/Ice/LocatorInfo.cpp b/cpp/src/Ice/LocatorInfo.cpp
index 15ea04f2187..b4ea96998b1 100644
--- a/cpp/src/Ice/LocatorInfo.cpp
+++ b/cpp/src/Ice/LocatorInfo.cpp
@@ -745,12 +745,12 @@ IceInternal::LocatorInfo::getEndpointsException(const ReferencePtr& ref, const I
Trace out(ref->getInstance()->initializationData().logger,
ref->getInstance()->traceLevels()->locationCat);
out << "object not found" << "\n";
- out << "object = " << Ice::identityToString(ref->getIdentity());
+ out << "object = " << ref->getInstance()->identityToString(ref->getIdentity());
}
NotRegisteredException ex(__FILE__, __LINE__);
ex.kindOfObject = "object";
- ex.id = Ice::identityToString(ref->getIdentity());
+ ex.id = ref->getInstance()->identityToString(ref->getIdentity());
throw ex;
}
catch(const NotRegisteredException&)
@@ -765,7 +765,7 @@ IceInternal::LocatorInfo::getEndpointsException(const ReferencePtr& ref, const I
out << "couldn't contact the locator to retrieve adapter endpoints\n";
if(ref->getAdapterId().empty())
{
- out << "object = " << Ice::identityToString(ref->getIdentity()) << "\n";
+ out << "object = " << ref->getInstance()->identityToString(ref->getIdentity()) << "\n";
}
else
{
@@ -800,7 +800,7 @@ IceInternal::LocatorInfo::getEndpointsTrace(const ReferencePtr& ref,
if(ref->getAdapterId().empty())
{
out << "object\n";
- out << "object = " << Ice::identityToString(ref->getIdentity());
+ out << "object = " << ref->getInstance()->identityToString(ref->getIdentity());
}
else
{
@@ -823,7 +823,7 @@ IceInternal::LocatorInfo::trace(const string& msg, const ReferencePtr& ref, cons
}
else
{
- out << "object = " << Ice::identityToString(ref->getIdentity()) << '\n';
+ out << "object = " << ref->getInstance()->identityToString(ref->getIdentity()) << '\n';
}
const char* sep = endpoints.size() > 1 ? ":" : "";
@@ -861,7 +861,7 @@ IceInternal::LocatorInfo::getObjectRequest(const ReferencePtr& ref)
if(ref->getInstance()->traceLevels()->location >= 1)
{
Trace out(ref->getInstance()->initializationData().logger, ref->getInstance()->traceLevels()->locationCat);
- out << "searching for object by id\nobject = " << Ice::identityToString(ref->getIdentity());
+ out << "searching for object by id\nobject = " << ref->getInstance()->identityToString(ref->getIdentity());
}
map<Ice::Identity, RequestPtr>::const_iterator p = _objectRequests.find(ref->getIdentity());
diff --git a/cpp/src/Ice/ObjectAdapterI.cpp b/cpp/src/Ice/ObjectAdapterI.cpp
index 2513179cbc3..220811dda07 100644
--- a/cpp/src/Ice/ObjectAdapterI.cpp
+++ b/cpp/src/Ice/ObjectAdapterI.cpp
@@ -958,7 +958,7 @@ Ice::ObjectAdapterI::initialize(const RouterPrx& router)
if(_routerInfo->getAdapter())
{
throw AlreadyRegisteredException(__FILE__, __LINE__, "object adapter with router",
- Ice::identityToString(router->ice_getIdentity()));
+ _instance->identityToString(router->ice_getIdentity()));
}
//
diff --git a/cpp/src/Ice/Reference.cpp b/cpp/src/Ice/Reference.cpp
index 5425b17c372..c461535c33e 100644
--- a/cpp/src/Ice/Reference.cpp
+++ b/cpp/src/Ice/Reference.cpp
@@ -233,7 +233,7 @@ IceInternal::Reference::toString() const
// the reference parser uses as separators, then we enclose
// the identity string in quotes.
//
- string id = Ice::identityToString(_identity);
+ string id = _instance->identityToString(_identity);
if(id.find_first_of(" :@") != string::npos)
{
s << '"' << id << '"';
diff --git a/cpp/src/Ice/ReferenceFactory.cpp b/cpp/src/Ice/ReferenceFactory.cpp
index f3df46b5427..24c5d1d384b 100644
--- a/cpp/src/Ice/ReferenceFactory.cpp
+++ b/cpp/src/Ice/ReferenceFactory.cpp
@@ -155,7 +155,7 @@ IceInternal::ReferenceFactory::create(const string& str, const string& propertyP
//
// Parsing the identity may raise IdentityParseException.
//
- Identity ident = Ice::stringToIdentity(idstr);
+ Identity ident = _instance->stringToIdentity(idstr);
if(ident.name.empty())
{
//
diff --git a/cpp/src/Ice/ServantManager.cpp b/cpp/src/Ice/ServantManager.cpp
index 2d95dc1027d..be20f45e704 100644
--- a/cpp/src/Ice/ServantManager.cpp
+++ b/cpp/src/Ice/ServantManager.cpp
@@ -44,7 +44,7 @@ IceInternal::ServantManager::addServant(const ObjectPtr& object, const Identity&
{
AlreadyRegisteredException ex(__FILE__, __LINE__);
ex.kindOfObject = "servant";
- ex.id = Ice::identityToString(ident);
+ ex.id = _instance->identityToString(ident);
if(!facet.empty())
{
string fs = nativeToUTF8(facet, _instance->getStringConverter());
@@ -104,7 +104,7 @@ IceInternal::ServantManager::removeServant(const Identity& ident, const string&
{
NotRegisteredException ex(__FILE__, __LINE__);
ex.kindOfObject = "servant";
- ex.id = Ice::identityToString(ident);
+ ex.id = _instance->identityToString(ident);
if(!facet.empty())
{
string fs = nativeToUTF8(facet, _instance->getStringConverter());
@@ -178,7 +178,7 @@ IceInternal::ServantManager::removeAllFacets(const Identity& ident)
{
NotRegisteredException ex(__FILE__, __LINE__);
ex.kindOfObject = "servant";
- ex.id = Ice::identityToString(ident);
+ ex.id = _instance->identityToString(ident);
throw ex;
}
diff --git a/cpp/src/Ice/TraceUtil.cpp b/cpp/src/Ice/TraceUtil.cpp
index 09634522617..c0c19e7a22b 100644
--- a/cpp/src/Ice/TraceUtil.cpp
+++ b/cpp/src/Ice/TraceUtil.cpp
@@ -30,7 +30,7 @@ printIdentityFacetOperation(ostream& s, BasicStream& stream)
{
Identity identity;
stream.read(identity);
- s << "\nidentity = " << Ice::identityToString(identity);
+ s << "\nidentity = " << stream.instance()->identityToString(identity);
vector<string> facet;
stream.read(facet);