improved pgp cleaning function

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5335 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2012-07-27 14:08:35 +00:00
parent da8a8ec659
commit a28786513e

View File

@ -41,6 +41,10 @@ end tag we take care of cases like ----- END XPGP . Here extra empty spaces h
introduced and the actual tag should have been -----END XPGP
*/
static bool is_acceptable_radix64Char(char c)
{
return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || c == '+' || c == '/' ;
}
std::string cleanUpCertificate(const std::string& badCertificate,int& error_code)
{
@ -262,20 +266,24 @@ std::string cleanUpCertificate(const std::string& badCertificate,int& error_code
}
if(badCertificate[currBadCertIdx]=='=') /* checksum */
{
cntPerLine=0 ;
break;
}
else if(badCertificate[currBadCertIdx]=='\t')
currBadCertIdx++;
else if(badCertificate[currBadCertIdx]==' ')
currBadCertIdx++;
else if(badCertificate[currBadCertIdx]=='\n')
currBadCertIdx++;
else
else if(is_acceptable_radix64Char(badCertificate[currBadCertIdx]))
{
cleanCertificate += badCertificate[currBadCertIdx];
cntPerLine++;
currBadCertIdx++;
}
else
{
std::cerr << "Warning: Invalid character in radix certificate encoding: " << badCertificate[currBadCertIdx] << std::endl;
currBadCertIdx++;
}
}
if(currBadCertIdx>=endCertStartIdx1)
{