Added method for URI escaping an entire list of characters.
Escape status detail characters that may disturb status parsing. git-svn-id: http://voip.null.ro/svn/yate@6184 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
8393e4a963
commit
afbeb65da9
|
@ -1612,7 +1612,9 @@ void Driver::statusDetail(String& str)
|
||||||
ObjList* l = m_chans.skipNull();
|
ObjList* l = m_chans.skipNull();
|
||||||
for (; l; l=l->skipNext()) {
|
for (; l; l=l->skipNext()) {
|
||||||
Channel* c = static_cast<Channel*>(l->get());
|
Channel* c = static_cast<Channel*>(l->get());
|
||||||
str.append(c->id(),",") << "=" << c->status() << "|" << c->address() << "|" << c->getPeerId();
|
str.append(c->id(),",") << "=" << c->status()
|
||||||
|
<< "|" << String::uriEscape(c->address(),",;|"," +?&")
|
||||||
|
<< "|" << c->getPeerId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1451,8 +1451,24 @@ String String::uriEscape(const char* str, char extraEsc, const char* noEsc)
|
||||||
return s;
|
return s;
|
||||||
char c;
|
char c;
|
||||||
while ((c=*str++)) {
|
while ((c=*str++)) {
|
||||||
if ((unsigned char)c <= ' ' || c == '%' || c == extraEsc ||
|
if ((unsigned char)c < ' ' || c == '%' || c == extraEsc ||
|
||||||
((c == '+' || c == '?' || c == '&') && !(noEsc && ::strchr(noEsc,c))))
|
((c == ' ' || c == '+' || c == '?' || c == '&') && !(noEsc && ::strchr(noEsc,c))))
|
||||||
|
s << '%' << hexEncode(c >> 4) << hexEncode(c);
|
||||||
|
else
|
||||||
|
s += c;
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
String String::uriEscape(const char* str, const char* extraEsc, const char* noEsc)
|
||||||
|
{
|
||||||
|
String s;
|
||||||
|
if (TelEngine::null(str))
|
||||||
|
return s;
|
||||||
|
char c;
|
||||||
|
while ((c=*str++)) {
|
||||||
|
if ((unsigned char)c < ' ' || c == '%' || (extraEsc && ::strchr(extraEsc,c)) ||
|
||||||
|
((c == ' ' || c == '+' || c == '?' || c == '&') && !(noEsc && ::strchr(noEsc,c))))
|
||||||
s << '%' << hexEncode(c >> 4) << hexEncode(c);
|
s << '%' << hexEncode(c >> 4) << hexEncode(c);
|
||||||
else
|
else
|
||||||
s += c;
|
s += c;
|
||||||
|
|
|
@ -415,8 +415,9 @@ void CdrBuilder::emit(const char *operation)
|
||||||
String CdrBuilder::getStatus() const
|
String CdrBuilder::getStatus() const
|
||||||
{
|
{
|
||||||
String s(m_status);
|
String s(m_status);
|
||||||
s << "|" << getValue(YSTRING("caller")) << "|" << getValue(YSTRING("called")) <<
|
s << "|" << String::uriEscape(getValue(YSTRING("caller")),",;|"," +?&")
|
||||||
"|" << getValue(YSTRING("billid"));
|
<< "|" << String::uriEscape(getValue(YSTRING("called")),",;|"," +?&")
|
||||||
|
<< "|" << String::uriEscape(getValue(YSTRING("billid")),",;|"," +?&");
|
||||||
unsigned int sec = 0;
|
unsigned int sec = 0;
|
||||||
if (m_start)
|
if (m_start)
|
||||||
sec = (int)((Time::now() - m_start + 500000) / 1000000);
|
sec = (int)((Time::now() - m_start + 500000) / 1000000);
|
||||||
|
|
|
@ -234,7 +234,7 @@ bool StatusHandler::received(Message &msg)
|
||||||
first = false;
|
first = false;
|
||||||
else
|
else
|
||||||
msg.retValue() << ",";
|
msg.retValue() << ",";
|
||||||
msg.retValue() << *acct << "=" << user;
|
msg.retValue() << *acct << "=" << String::uriEscape(user,",;|"," +?&");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
msg.retValue() << "\r\n";
|
msg.retValue() << "\r\n";
|
||||||
|
|
|
@ -42,7 +42,7 @@ public:
|
||||||
virtual bool msgOperation(Message& msg, const String& operation);
|
virtual bool msgOperation(Message& msg, const String& operation);
|
||||||
void chanReplaced(const String& initial, const String& final);
|
void chanReplaced(const String& initial, const String& final);
|
||||||
inline void statusDetail(String& str) const
|
inline void statusDetail(String& str) const
|
||||||
{ str.append(id() + "=" + m_state + "|" + m_tones,","); }
|
{ str.append(id() + "=" + m_state + "|" + String::uriEscape(m_tones,",;|"," +?&"),","); }
|
||||||
protected:
|
protected:
|
||||||
inline const String& state() const
|
inline const String& state() const
|
||||||
{ return m_state; }
|
{ return m_state; }
|
||||||
|
|
|
@ -2739,6 +2739,15 @@ public:
|
||||||
*/
|
*/
|
||||||
static String uriEscape(const char* str, char extraEsc = 0, const char* noEsc = 0);
|
static String uriEscape(const char* str, char extraEsc = 0, const char* noEsc = 0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an escaped string suitable for use in URIs
|
||||||
|
* @param str String to convert to escaped format
|
||||||
|
* @param extraEsc Pointer to string of characters to escape other than the defaults
|
||||||
|
* @param noEsc Optional pointer to string of characters that shouldn't be escaped
|
||||||
|
* @return The string with special characters escaped
|
||||||
|
*/
|
||||||
|
static String uriEscape(const char* str, const char* extraEsc, const char* noEsc = 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an escaped string suitable for use in URI
|
* Create an escaped string suitable for use in URI
|
||||||
* @param extraEsc Character to escape other than the default ones
|
* @param extraEsc Character to escape other than the default ones
|
||||||
|
|
Loading…
Reference in New Issue