mirror of
https://github.com/pocoproject/poco.git
synced 2025-11-04 12:17:37 +01:00
trunk/branch integration: bugfix
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// URI.cpp
|
// URI.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/src/URI.cpp#15 $
|
// $Id: //poco/1.4/Foundation/src/URI.cpp#4 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: URI
|
// Package: URI
|
||||||
@@ -229,6 +229,10 @@ std::string URI::toString() const
|
|||||||
uri += '/';
|
uri += '/';
|
||||||
encode(_path, RESERVED_PATH, uri);
|
encode(_path, RESERVED_PATH, uri);
|
||||||
}
|
}
|
||||||
|
else if (!_query.empty() || !_fragment.empty())
|
||||||
|
{
|
||||||
|
uri += '/';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!_query.empty())
|
if (!_query.empty())
|
||||||
{
|
{
|
||||||
@@ -289,7 +293,13 @@ std::string URI::getAuthority() const
|
|||||||
auth.append(_userInfo);
|
auth.append(_userInfo);
|
||||||
auth += '@';
|
auth += '@';
|
||||||
}
|
}
|
||||||
auth.append(_host);
|
if (_host.find(':') != std::string::npos)
|
||||||
|
{
|
||||||
|
auth += '[';
|
||||||
|
auth += _host;
|
||||||
|
auth += ']';
|
||||||
|
}
|
||||||
|
else auth.append(_host);
|
||||||
if (_port && !isWellKnownPort())
|
if (_port && !isWellKnownPort())
|
||||||
{
|
{
|
||||||
auth += ':';
|
auth += ':';
|
||||||
@@ -363,7 +373,7 @@ std::string URI::getPathEtc() const
|
|||||||
if (!_query.empty())
|
if (!_query.empty())
|
||||||
{
|
{
|
||||||
pathEtc += '?';
|
pathEtc += '?';
|
||||||
pathEtc.append(_query);
|
pathEtc += _query;
|
||||||
}
|
}
|
||||||
if (!_fragment.empty())
|
if (!_fragment.empty())
|
||||||
{
|
{
|
||||||
@@ -381,7 +391,7 @@ std::string URI::getPathAndQuery() const
|
|||||||
if (!_query.empty())
|
if (!_query.empty())
|
||||||
{
|
{
|
||||||
pathAndQuery += '?';
|
pathAndQuery += '?';
|
||||||
encode(_query, RESERVED_QUERY, pathAndQuery);
|
pathAndQuery += _query;
|
||||||
}
|
}
|
||||||
return pathAndQuery;
|
return pathAndQuery;
|
||||||
}
|
}
|
||||||
@@ -567,9 +577,9 @@ void URI::encode(const std::string& str, const std::string& reserved, std::strin
|
|||||||
for (std::string::const_iterator it = str.begin(); it != str.end(); ++it)
|
for (std::string::const_iterator it = str.begin(); it != str.end(); ++it)
|
||||||
{
|
{
|
||||||
char c = *it;
|
char c = *it;
|
||||||
if (c >= 'a' && c <= 'z' ||
|
if ((c >= 'a' && c <= 'z') ||
|
||||||
c >= 'A' && c <= 'Z' ||
|
(c >= 'A' && c <= 'Z') ||
|
||||||
c >= '0' && c <= '9' ||
|
(c >= '0' && c <= '9') ||
|
||||||
c == '-' || c == '_' ||
|
c == '-' || c == '_' ||
|
||||||
c == '.' || c == '~')
|
c == '.' || c == '~')
|
||||||
{
|
{
|
||||||
@@ -641,6 +651,14 @@ unsigned short URI::getWellKnownPort() const
|
|||||||
return 389;
|
return 389;
|
||||||
else if (_scheme == "https")
|
else if (_scheme == "https")
|
||||||
return 443;
|
return 443;
|
||||||
|
else if (_scheme == "rtsp")
|
||||||
|
return 554;
|
||||||
|
else if (_scheme == "sip")
|
||||||
|
return 5060;
|
||||||
|
else if (_scheme == "sips")
|
||||||
|
return 5061;
|
||||||
|
else if (_scheme == "xmpp")
|
||||||
|
return 5222;
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -710,9 +728,10 @@ void URI::parseHostAndPort(std::string::const_iterator& it, const std::string::c
|
|||||||
if (*it == '[')
|
if (*it == '[')
|
||||||
{
|
{
|
||||||
// IPv6 address
|
// IPv6 address
|
||||||
|
++it;
|
||||||
while (it != end && *it != ']') host += *it++;
|
while (it != end && *it != ']') host += *it++;
|
||||||
if (it == end) throw SyntaxException("unterminated IPv6 address");
|
if (it == end) throw SyntaxException("unterminated IPv6 address");
|
||||||
host += *it++;
|
++it;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -794,8 +813,8 @@ void URI::mergePath(const std::string& path)
|
|||||||
addLeadingSlash = _path[0] == '/';
|
addLeadingSlash = _path[0] == '/';
|
||||||
}
|
}
|
||||||
getPathSegments(path, segments);
|
getPathSegments(path, segments);
|
||||||
addLeadingSlash = addLeadingSlash || !path.empty() && path[0] == '/';
|
addLeadingSlash = addLeadingSlash || (!path.empty() && path[0] == '/');
|
||||||
bool hasTrailingSlash = !path.empty() && *(path.rbegin()) == '/';
|
bool hasTrailingSlash = (!path.empty() && *(path.rbegin()) == '/');
|
||||||
bool addTrailingSlash = false;
|
bool addTrailingSlash = false;
|
||||||
for (std::vector<std::string>::const_iterator it = segments.begin(); it != segments.end(); ++it)
|
for (std::vector<std::string>::const_iterator it = segments.begin(); it != segments.end(); ++it)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user