Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4343,7 +4343,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
vRecv >> addrFrom >> nNonce;
if (!vRecv.empty()) {
vRecv >> LIMITED_STRING(pfrom->strSubVer, 256);
pfrom->cleanSubVer = SanitizeString(pfrom->strSubVer);
pfrom->cleanSubVer = SanitizeSubVersionString(pfrom->strSubVer);
}
if (!vRecv.empty())
vRecv >> pfrom->nStartingHeight;
Expand Down
11 changes: 11 additions & 0 deletions src/utilstrencodings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ string SanitizeString(const string& str)
return strResult;
}

/// Formats the network peer user agent text (or clean subversion)
/// by removing the begining and ending charactors(/).
/// example: /Dash Core:0.12.0.56/ --> Dash Core:0.12.0.56
string SanitizeSubVersionString(const string& str)
{
string strResult = SanitizeString(str);
if ((strResult.length() > 3) && (strResult.substr(0,1) == "/") && (strResult.substr((strResult.length()-1),1) == "/"))
strResult = strResult.substr(1, (strResult.length() - 2));
return strResult;
}

const signed char p_util_hexdigit[256] =
{ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
Expand Down
1 change: 1 addition & 0 deletions src/utilstrencodings.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#define PAIRTYPE(t1, t2) std::pair<t1, t2>

std::string SanitizeString(const std::string& str);
std::string SanitizeSubVersionString(const std::string& str);
std::vector<unsigned char> ParseHex(const char* psz);
std::vector<unsigned char> ParseHex(const std::string& str);
signed char HexDigit(char c);
Expand Down