summaryrefslogtreecommitdiff
path: root/protocols/FacebookRM/src
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2014-08-07 02:02:07 +0000
committerRobert Pösel <robyer@seznam.cz>2014-08-07 02:02:07 +0000
commitbfa54f92fa14defbb276e57ad7508bd68318f592 (patch)
treedc5e8e490475c3a6974d9ecccfd564f91a93f86f /protocols/FacebookRM/src
parent523df843b25d660da107d6e954fa2127bf02e082 (diff)
Facebook: Fix sending "&#123456" in message
- Remove "special_expressions_decode" from various wrong places (hopefully it won't cause any new problems) - Rename it to "html_entities_decode" git-svn-id: http://svn.miranda-ng.org/main/trunk@10104 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM/src')
-rw-r--r--protocols/FacebookRM/src/communication.cpp8
-rw-r--r--protocols/FacebookRM/src/contacts.cpp2
-rw-r--r--protocols/FacebookRM/src/json.cpp22
-rw-r--r--protocols/FacebookRM/src/process.cpp16
-rw-r--r--protocols/FacebookRM/src/utils.cpp2
-rw-r--r--protocols/FacebookRM/src/utils.h2
6 files changed, 26 insertions, 26 deletions
diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp
index 6064378b10..7145355a7e 100644
--- a/protocols/FacebookRM/src/communication.cpp
+++ b/protocols/FacebookRM/src/communication.cpp
@@ -135,7 +135,7 @@ http::response facebook_client::flap(RequestType request_type, std::string* requ
if (pos != std::string::npos) {
pos += 20;
error = resp.data.substr(pos, resp.data.find("\"", pos) - pos);
- error = utils::text::trim(utils::text::special_expressions_decode(utils::text::slashu_to_utf8(error)));
+ error = utils::text::trim(utils::text::html_entities_decode(utils::text::slashu_to_utf8(error)));
error = ptrA( mir_utf8decodeA(error.c_str()));
}
@@ -144,7 +144,7 @@ http::response facebook_client::flap(RequestType request_type, std::string* requ
if (pos != std::string::npos) {
pos += 16;
title = resp.data.substr(pos, resp.data.find("\"", pos) - pos);
- title = utils::text::trim(utils::text::special_expressions_decode(utils::text::slashu_to_utf8(title)));
+ title = utils::text::trim(utils::text::html_entities_decode(utils::text::slashu_to_utf8(title)));
title = ptrA( mir_utf8decodeA(title.c_str()));
}
@@ -723,7 +723,7 @@ void facebook_client::clear_chatrooms()
void loginError(FacebookProto *proto, std::string error_str) {
error_str = utils::text::trim(
- utils::text::special_expressions_decode(
+ utils::text::html_entities_decode(
utils::text::remove_html(
utils::text::edit_html(error_str))));
@@ -1294,7 +1294,7 @@ bool facebook_client::post_status(status_data *status)
data += "&__user=" + (status->isPage && !status->user_id.empty() ? status->user_id : this->self_.user_id);
data += "&loaded_components[0]=maininput&loaded_components[1]=backdateicon&loaded_components[2]=withtaggericon&loaded_components[3]=cameraicon&loaded_components[4]=placetaggericon&loaded_components[5]=mainprivacywidget&loaded_components[6]=withtaggericon&loaded_components[7]=backdateicon&loaded_components[8]=placetaggericon&loaded_components[9]=cameraicon&loaded_components[10]=mainprivacywidget&loaded_components[11]=maininput&loaded_components[12]=explicitplaceinput&loaded_components[13]=hiddenplaceinput&loaded_components[14]=placenameinput&loaded_components[15]=hiddensessionid&loaded_components[16]=withtagger&loaded_components[17]=backdatepicker&loaded_components[18]=placetagger&loaded_components[19]=citysharericon";
http::response resp = flap(REQUEST_LINK_SCRAPER, &data, &status->url);
- resp.data = utils::text::special_expressions_decode(utils::text::slashu_to_utf8(resp.data));
+ resp.data = utils::text::slashu_to_utf8(resp.data);
data = "&xhpc_context=profile&xhpc_ismeta=1&xhpc_timeline=1&xhpc_composerid=u_jsonp_2_0&is_explicit_place=&composertags_place=&composer_session_id=&composertags_city=&disable_location_sharing=false&composer_predicted_city=&nctr[_mod]=pagelet_composer&__a=1&__dyn=&__req=1f&ttstamp=0";
std::string form = utils::text::source_get_value(&resp.data, 2, "<form", "</form>");
diff --git a/protocols/FacebookRM/src/contacts.cpp b/protocols/FacebookRM/src/contacts.cpp
index 0d4953494f..ed8b3cdabe 100644
--- a/protocols/FacebookRM/src/contacts.cpp
+++ b/protocols/FacebookRM/src/contacts.cpp
@@ -580,7 +580,7 @@ void FacebookProto::SendPokeWorker(void *p)
if (message.empty()) // message has different format, show whole message
message = resp.data;
- message = utils::text::special_expressions_decode(
+ message = utils::text::html_entities_decode(
utils::text::remove_html(message));
ptrT tmessage( mir_utf8decodeT(message.c_str()));
diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp
index 0c2c0024ce..0bfceb4287 100644
--- a/protocols/FacebookRM/src/json.cpp
+++ b/protocols/FacebookRM/src/json.cpp
@@ -151,9 +151,9 @@ int facebook_json_parser::parse_buddy_list(void* data, List::List< facebook_user
JSONNODE *thumbSrc = json_get(it, "thumbSrc");
if (name != NULL)
- current->real_name = utils::text::slashu_to_utf8(utils::text::special_expressions_decode(json_as_pstring(name)));
+ current->real_name = utils::text::slashu_to_utf8(json_as_pstring(name));
if (thumbSrc != NULL)
- current->image_url = utils::text::slashu_to_utf8(utils::text::special_expressions_decode(json_as_pstring(thumbSrc)));
+ current->image_url = utils::text::slashu_to_utf8(json_as_pstring(thumbSrc));
}
}
@@ -181,11 +181,11 @@ void parseUser(JSONNODE *it, facebook_user *fbu)
if (name)
- fbu->real_name = utils::text::slashu_to_utf8(utils::text::special_expressions_decode(json_as_pstring(name)));
+ fbu->real_name = utils::text::slashu_to_utf8(json_as_pstring(name));
if (thumbSrc)
- fbu->image_url = utils::text::slashu_to_utf8(utils::text::special_expressions_decode(json_as_pstring(thumbSrc)));
+ fbu->image_url = utils::text::slashu_to_utf8(json_as_pstring(thumbSrc));
if (vanity)
- fbu->username = utils::text::slashu_to_utf8(utils::text::special_expressions_decode(json_as_pstring(vanity)));
+ fbu->username = utils::text::slashu_to_utf8(json_as_pstring(vanity));
if (gender)
switch (json_as_int(gender)) {
@@ -259,7 +259,7 @@ int facebook_json_parser::parse_notifications(void *data, std::map< std::string,
if (markup == NULL || unread == NULL || json_as_int(unread) == 0)
continue;
- std::string text = utils::text::slashu_to_utf8(utils::text::special_expressions_decode(json_as_pstring(markup)));
+ std::string text = utils::text::slashu_to_utf8(json_as_pstring(markup));
facebook_notification* notification = new facebook_notification();
@@ -518,7 +518,7 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa
if (json_as_bool(filtered) && message_text.empty())
message_text = Translate("This message is no longer available, because it was marked as abusive or spam.");
- message_text = utils::text::trim(utils::text::special_expressions_decode(utils::text::slashu_to_utf8(message_text)), true);
+ message_text = utils::text::trim(utils::text::slashu_to_utf8(message_text), true);
if (message_text.empty())
continue;
@@ -529,7 +529,7 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa
message->time = utils::time::fix_timestamp(json_as_float(timestamp));
message->user_id = id;
message->message_id = message_id;
- message->sender_name = utils::text::special_expressions_decode(utils::text::slashu_to_utf8(json_as_pstring(sender_name))); // TODO: or if not incomming use my own name from facy.self_ ?
+ message->sender_name = utils::text::slashu_to_utf8(json_as_pstring(sender_name)); // TODO: or if not incomming use my own name from facy.self_ ?
message->thread_id = json_as_pstring(tid); // TODO: or if not incomming use my own id from facy.self_ ?
JSONNODE *gthreadinfo = json_get(msg, "group_thread_info");
@@ -571,7 +571,7 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa
facebook_notification* notification = new facebook_notification();
notification->text = utils::text::slashu_to_utf8(json_as_pstring(text));
- notification->link = utils::text::special_expressions_decode(json_as_pstring(url));
+ notification->link = json_as_pstring(url);
notification->id = json_as_pstring(alert_id);
std::string::size_type pos = notification->id.find(":");
@@ -674,7 +674,7 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa
text = utils::text::slashu_to_utf8(text);
text = utils::text::trim(
- utils::text::special_expressions_decode(
+ utils::text::html_entities_decode(
utils::text::source_get_value(&text, 3, "<h5", ">", "</h5>")));
// TODO: notify ticker updates
@@ -885,7 +885,7 @@ int facebook_json_parser::parse_thread_messages(void* data, std::vector< faceboo
if (json_as_bool(filtered) && message_text.empty())
message_text = Translate("This message is no longer available, because it was marked as abusive or spam.");
- message_text = utils::text::trim(utils::text::special_expressions_decode(utils::text::slashu_to_utf8(message_text)), true);
+ message_text = utils::text::trim(utils::text::slashu_to_utf8(message_text), true);
if (message_text.empty())
continue;
diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp
index a0a7980da7..dfc9225151 100644
--- a/protocols/FacebookRM/src/process.cpp
+++ b/protocols/FacebookRM/src/process.cpp
@@ -1021,12 +1021,12 @@ void FacebookProto::ProcessFeeds(void* data)
facebook_newsfeed* nf = new facebook_newsfeed;
nf->title = utils::text::trim(
- utils::text::special_expressions_decode(
+ utils::text::html_entities_decode(
utils::text::remove_html(post_header)));
nf->user_id = utils::text::source_get_value(&post_header, 2, "user.php?id=", "&amp;");
- nf->link = utils::text::special_expressions_decode(post_link);
+ nf->link = utils::text::html_entities_decode(post_link);
// Check if we don't want to show ads posts
bool filtered = filterAds && (nf->link.find("/about/ads") != std::string::npos
@@ -1034,7 +1034,7 @@ void FacebookProto::ProcessFeeds(void* data)
|| post.find("href=\"/about/ads\"") != std::string::npos);
nf->text = utils::text::trim(
- utils::text::special_expressions_decode(
+ utils::text::html_entities_decode(
utils::text::remove_html(
utils::text::edit_html(post_message))));
@@ -1116,7 +1116,7 @@ void FacebookProto::ProcessPages(void*)
start = content.find("<li", start + 1);
std::string id = utils::text::source_get_value(&item, 3, "data-gt=", "bmid&quot;:&quot;", "&quot;");
- std::string title = utils::text::special_expressions_decode(utils::text::slashu_to_utf8(utils::text::source_get_value(&item, 3, "data-gt=", "title=\"", "\"")));
+ std::string title = utils::text::slashu_to_utf8(utils::text::source_get_value(&item, 3, "data-gt=", "title=\"", "\""));
std::string href = utils::text::source_get_value(&item, 3, "data-gt=", "href=\"", "\"");
// Ignore pages channel
@@ -1186,10 +1186,10 @@ void FacebookProto::SearchAckThread(void *targ)
continue;
ptrT tid( mir_utf8decodeT(id.c_str()));
- ptrT tname( mir_utf8decodeT(utils::text::special_expressions_decode(name).c_str()));
- ptrT tsurname( mir_utf8decodeT(utils::text::special_expressions_decode(surname).c_str()));
- ptrT tnick( mir_utf8decodeT(utils::text::special_expressions_decode(nick).c_str()));
- ptrT tcommon( mir_utf8decodeT(utils::text::special_expressions_decode(common).c_str()));
+ ptrT tname( mir_utf8decodeT(utils::text::html_entities_decode(name).c_str()));
+ ptrT tsurname( mir_utf8decodeT(utils::text::html_entities_decode(surname).c_str()));
+ ptrT tnick( mir_utf8decodeT(utils::text::html_entities_decode(nick).c_str()));
+ ptrT tcommon( mir_utf8decodeT(utils::text::html_entities_decode(common).c_str()));
PROTOSEARCHRESULT isr = {0};
isr.cbSize = sizeof(isr);
diff --git a/protocols/FacebookRM/src/utils.cpp b/protocols/FacebookRM/src/utils.cpp
index 115a5d4350..6b03f523f3 100644
--- a/protocols/FacebookRM/src/utils.cpp
+++ b/protocols/FacebookRM/src/utils.cpp
@@ -150,7 +150,7 @@ void utils::text::append_ordinal(unsigned long value, std::string* data)
}
}
-std::string utils::text::special_expressions_decode(std::string data)
+std::string utils::text::html_entities_decode(std::string data)
{
utils::text::replace_all(&data, "&amp;", "&");
utils::text::replace_all(&data, "&quot;", "\"");
diff --git a/protocols/FacebookRM/src/utils.h b/protocols/FacebookRM/src/utils.h
index 19ae46b97c..69315ae1e0 100644
--- a/protocols/FacebookRM/src/utils.h
+++ b/protocols/FacebookRM/src/utils.h
@@ -56,7 +56,7 @@ namespace utils
void replace_first(std::string* data, std::string from, std::string to);
void replace_all(std::string* data, std::string from, std::string to);
unsigned int count_all(std::string* data, std::string term);
- std::string special_expressions_decode(std::string data);
+ std::string html_entities_decode(std::string data);
std::string edit_html(std::string data);
std::string remove_html(std::string data);
std::string slashu_to_utf8(std::string data);