Browse Source

Merge branch 'master' of github.com:miguelfreitas/twister-core

miguelfreitas v0.9.21
Miguel Freitas 11 years ago
parent
commit
1e6f152de0
  1. 19
      src/twister_rss.cpp
  2. 1
      src/twister_rss.h

19
src/twister_rss.cpp

@ -102,6 +102,7 @@ int generateRSS(string uri, string *output)
postTitle="Direct Message from "+postAuthor; postTitle="Direct Message from "+postAuthor;
postMsg=find_value(userArray[i].get_obj(),"text").get_str(); postMsg=find_value(userArray[i].get_obj(),"text").get_str();
Value postTime = find_value(userArray[i].get_obj(),"time"); Value postTime = find_value(userArray[i].get_obj(),"time");
encodeXmlCharacters(postMsg);
Object item; Object item;
item.push_back(Pair("time",postTime)); item.push_back(Pair("time",postTime));
@ -146,6 +147,7 @@ int generateRSS(string uri, string *output)
} }
Value postTime = find_value(userpost,"time"); Value postTime = find_value(userpost,"time");
encodeXmlCharacters(postMsg);
Object item; Object item;
item.push_back(Pair("time",postTime)); item.push_back(Pair("time",postTime));
@ -219,3 +221,20 @@ bool sortByTime (Object i,Object j)
{ {
return (find_value(i,"time").get_int64()>find_value(j,"time").get_int64()); return (find_value(i,"time").get_int64()>find_value(j,"time").get_int64());
} }
void encodeXmlCharacters(std::string& data)
{
std::string buffer;
buffer.reserve(data.size());
for(size_t pos = 0; pos != data.size(); ++pos) {
switch(data[pos]) {
case '&': buffer.append("&"); break;
case '\"': buffer.append("""); break;
case '\'': buffer.append("'"); break;
case '<': buffer.append("&lt;"); break;
case '>': buffer.append("&gt;"); break;
default: buffer.append(&data[pos], 1); break;
}
}
data.swap(buffer);
}

1
src/twister_rss.h

@ -15,6 +15,7 @@ enum RSSResultCode
}; };
extern bool sortByTime (json_spirit::Object i,json_spirit::Object j); extern bool sortByTime (json_spirit::Object i,json_spirit::Object j);
extern void encodeXmlCharacters (std::string& data);
#ifdef HAVE_BOOST_REGEX #ifdef HAVE_BOOST_REGEX
extern std::map<std::string, std::string> parseQuery(const std::string& query); extern std::map<std::string, std::string> parseQuery(const std::string& query);
#endif #endif

Loading…
Cancel
Save