FeedReader:

- Remove "sid=" from link
Moved stringToUpperCase and stringToLowerCase from rsinit.cc to util/rsstring.cc


git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6029 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2012-12-22 21:01:45 +00:00
parent e66a9117e2
commit 0f26b85a88
4 changed files with 44 additions and 44 deletions

View File

@ -201,28 +201,6 @@ bool RsInitConfig::udpListenerOnly;
static bool getAvailableAccounts(std::list<accountId> &ids,int& failing_accounts,std::map<std::string,std::vector<std::string> >& unsupported_keys);
static bool checkAccount(std::string accountdir, accountId &id,std::map<std::string,std::vector<std::string> >& unsupported_keys);
static std::string toUpperCase(const std::string& s)
{
std::string res(s) ;
for(uint32_t i=0;i<res.size();++i)
if(res[i] > 96 && res[i] < 123)
res[i] -= 97-65 ;
return res ;
}
static std::string toLowerCase(const std::string& s)
{
std::string res(s) ;
for(uint32_t i=0;i<res.size();++i)
if(res[i] > 64 && res[i] < 91)
res[i] += 97-65 ;
return res ;
}
void RsInit::InitRsConfig()
{
#ifndef WINDOWS_SYS
@ -655,8 +633,10 @@ int RsInit::InitRetroShare(int argcIgnored, char **argvIgnored, bool strictCheck
// if a different user id has been passed to cmd line check for that instead
std::string lower_case_user_string = toLowerCase(prefUserString) ;
std::string upper_case_user_string = toUpperCase(prefUserString) ;
std::string lower_case_user_string;
stringToLowerCase(prefUserString, lower_case_user_string) ;
std::string upper_case_user_string;
stringToUpperCase(prefUserString, upper_case_user_string) ;
bool pgpNameFound = false;
if(prefUserString != "")

View File

@ -269,3 +269,21 @@ int rs_sprintf_append(std::string &str, const char *fmt, ...)
return retval;
}
void stringToUpperCase(const std::string& s, std::string &upper)
{
upper = s ;
for(uint32_t i=0;i<upper.size();++i)
if(upper[i] > 96 && upper[i] < 123)
upper[i] -= 97-65 ;
}
void stringToLowerCase(const std::string& s, std::string &lower)
{
lower = s ;
for(uint32_t i=0;i<lower.size();++i)
if(lower[i] > 64 && lower[i] < 91)
lower[i] += 97-65 ;
}

View File

@ -42,4 +42,7 @@ bool ConvertUtf16ToUtf8(const std::wstring& source, std::string& dest);
int rs_sprintf(std::string &str, const char *fmt, ...);
int rs_sprintf_append(std::string &str, const char *fmt, ...);
void stringToUpperCase(const std::string& s, std::string &upper);
void stringToLowerCase(const std::string& s, std::string &lower);
#endif // RSSTRING_H_

View File

@ -863,29 +863,28 @@ RsFeedReaderErrorState p3FeedReaderThread::process(const RsFeedReaderFeed &feed,
xml.getChildText(node, "link", item->link);
}
long todo; // remove sid
// // remove sid=
// CString sLinkUpper = sLink;
// sLinkUpper.MakeUpper ();
// int nSIDStart = sLinkUpper.Find (TEXT("SID="));
// if (nSIDStart != -1) {
// int nSIDEnd1 = sLinkUpper.Find (TEXT(";"), nSIDStart);
// int nSIDEnd2 = sLinkUpper.Find (TEXT("#"), nSIDStart);
// remove sid=
std::string linkUpper;
stringToUpperCase(item->link, linkUpper);
std::string::size_type sidStart = linkUpper.find("SID=");
if (sidStart != std::string::npos) {
std::string::size_type sidEnd1 = linkUpper.find(";", sidStart);
std::string::size_type sidEnd2 = linkUpper.find("#", sidStart);
// if (nSIDEnd1 == -1) {
// nSIDEnd1 = sLinkUpper.GetLength ();
// }
// if (nSIDEnd2 == -1) {
// nSIDEnd2 = sLinkUpper.GetLength ();
// }
if (sidEnd1 == std::string::npos) {
sidEnd1 = linkUpper.size();
}
if (sidEnd2 == std::string::npos) {
sidEnd2 = linkUpper.size();
}
// if (nSIDStart > 0 && sLinkUpper [nSIDStart - 1] == '&') {
// nSIDStart--;
// }
if (sidStart > 0 && linkUpper[sidStart - 1] == '&') {
sidStart--;
}
// int nSIDEnd = min (nSIDEnd1, nSIDEnd2);
// sLink.Delete (nSIDStart, nSIDEnd - nSIDStart);
// }
std::string::size_type sidEnd = std::min(sidEnd1, sidEnd2);
item->link.erase(sidStart, sidEnd - sidStart);
}
xml.getChildText(node, "author", item->author);