Skip to content
This repository was archived by the owner on Apr 24, 2022. It is now read-only.

Commit 3ace385

Browse files
committedNov 1, 2018
Fix PoolUri parse error
- Fix logic preventing proper parse of URI fragment - Rename String method to conventional str for string view
1 parent d4ffcba commit 3ace385

File tree

4 files changed

+6
-8
lines changed

4 files changed

+6
-8
lines changed
 

‎libapicore/ApiServer.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ void ApiConnection::processRequest(Json::Value& jRequest, Json::Value& jResponse
502502
if (!uri.Valid())
503503
{
504504
jResponse["error"]["code"] = -422;
505-
jResponse["error"]["message"] = ("Invalid URI " + uri.String());
505+
jResponse["error"]["message"] = ("Invalid URI " + uri.str());
506506
return;
507507
}
508508
if (!uri.KnownScheme())
@@ -1022,7 +1022,7 @@ Json::Value ApiConnection::getMinerStatDetail()
10221022
/* connection info */
10231023
auto connection = PoolManager::p().getActiveConnectionCopy();
10241024
Json::Value jconnection;
1025-
jconnection["uri"] = connection.String();
1025+
jconnection["uri"] = connection.str();
10261026
// jconnection["endpoint"] = PoolManager::p().getClient()->ActiveEndPoint();
10271027
jconnection["isconnected"] = PoolManager::p().isConnected();
10281028
jconnection["switched"] = PoolManager::p().getConnectionSwitches();

‎libpoolprotocols/PoolManager.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ Json::Value PoolManager::getConnectionsJson()
370370
Json::Value JConn;
371371
JConn["index"] = (unsigned)i;
372372
JConn["active"] = (i == m_activeConnectionIdx ? true : false);
373-
JConn["uri"] = m_connections[i].String();
373+
JConn["uri"] = m_connections[i].str();
374374
jRes.append(JConn);
375375
}
376376

‎libpoolprotocols/PoolURI.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ URI::URI(const std::string uri)
230230
curstr++;
231231
// Read port number
232232
tmpstr = curstr;
233-
while (('\0' != *tmpstr) && ('/' != *tmpstr))
233+
while (('\0' != *tmpstr) && ('/' != *tmpstr) && ('#' != *tmpstr))
234234
tmpstr++;
235235
len = tmpstr - curstr;
236236
std::string tempstr;
@@ -252,11 +252,10 @@ URI::URI(const std::string uri)
252252
}
253253

254254
// Skip '/'
255-
if ('/' != *curstr)
255+
if (('/' != *curstr) && ('#' != *curstr))
256256
{
257257
return;
258258
}
259-
curstr++;
260259

261260
// Parse path
262261
tmpstr = curstr;
@@ -265,7 +264,6 @@ URI::URI(const std::string uri)
265264
len = tmpstr - curstr;
266265
if (len)
267266
{
268-
m_path = '/';
269267
m_path.append(curstr, len);
270268
m_path = urlDecode(m_path);
271269
}

‎libpoolprotocols/PoolURI.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class URI
6262
ProtocolFamily Family() const;
6363
UriHostNameType HostNameType() const;
6464
unsigned Version() const;
65-
std::string String() const { return m_uri; }
65+
std::string str() const { return m_uri; }
6666
bool Valid() const { return m_valid; }
6767

6868
bool KnownScheme();

0 commit comments

Comments
 (0)
This repository has been archived.