summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/Reference.cpp
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2002-08-27 18:46:05 +0000
committerMark Spruiell <mes@zeroc.com>2002-08-27 18:46:05 +0000
commitfcd354c185711a2936a053fdd22bf7deb5691705 (patch)
tree8ee9c346cfc28f17fad8079f56d253f7ed96c5d9 /cpp/src/Ice/Reference.cpp
parentinitial check-in (diff)
downloadice-fcd354c185711a2936a053fdd22bf7deb5691705.tar.bz2
ice-fcd354c185711a2936a053fdd22bf7deb5691705.tar.xz
ice-fcd354c185711a2936a053fdd22bf7deb5691705.zip
adding escapes for references, identity
Diffstat (limited to 'cpp/src/Ice/Reference.cpp')
-rw-r--r--cpp/src/Ice/Reference.cpp71
1 files changed, 56 insertions, 15 deletions
diff --git a/cpp/src/Ice/Reference.cpp b/cpp/src/Ice/Reference.cpp
index f98f1fd4e38..1e564818de9 100644
--- a/cpp/src/Ice/Reference.cpp
+++ b/cpp/src/Ice/Reference.cpp
@@ -19,6 +19,7 @@
#include <Ice/Router.h>
#include <Ice/LocatorInfo.h>
#include <Ice/Locator.h>
+#include <Ice/StringUtil.h>
using namespace std;
using namespace Ice;
@@ -235,23 +236,49 @@ IceInternal::Reference::toString() const
{
ostringstream s;
- s << identity;
+ //
+ // If the encoded identity string contains characters which
+ // the reference parser uses as separators, then we enclose
+ // the identity string in quotes.
+ //
+ string id = identityToString(identity);
+ if(id.find_first_of(" \t\n\r:@") != string::npos)
+ {
+ s << '"' << id << '"';
+ }
+ else
+ {
+ s << id;
+ }
if(!facet.empty())
{
- s << " -f ";
- vector<string>::const_iterator p = facet.begin();
- while(p != facet.end())
- {
- //
- // TODO: Escape for whitespace and slashes.
- //
- s << *p++;
- if(p != facet.end())
- {
- s << '/';
- }
- }
+ ostringstream f;
+ vector<string>::const_iterator p = facet.begin();
+ while(p != facet.end())
+ {
+ f << encodeString(*p++, "/");
+ if(p != facet.end())
+ {
+ f << '/';
+ }
+ }
+
+ //
+ // If the encoded facet string contains characters which
+ // the reference parser uses as separators, then we enclose
+ // the facet string in quotes.
+ //
+ s << " -f ";
+ const string& fs = f.str();
+ if(fs.find_first_of(" \t\n\r:@") != string::npos)
+ {
+ s << '"' << fs << '"';
+ }
+ else
+ {
+ s << fs;
+ }
}
switch(mode)
@@ -310,7 +337,21 @@ IceInternal::Reference::toString() const
}
else if(!adapterId.empty())
{
- s << " @ " << adapterId;
+ string a = encodeString(adapterId, "");
+ //
+ // If the encoded adapter id string contains characters which
+ // the reference parser uses as separators, then we enclose
+ // the adapter id string in quotes.
+ //
+ s << " @ ";
+ if(a.find_first_of(" \t\n\r") != string::npos)
+ {
+ s << '"' << a << '"';
+ }
+ else
+ {
+ s << adapterId;
+ }
}
return s.str();