aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2016-11-27 13:01:33 +0000
committerWilmer van der Gaast <wilmer@gaast.net>2016-11-27 13:01:33 +0000
commited1f5e8de07be7c90e2e8cd9020727d53d6b04c7 (patch)
treed14763bccefdcdfb592ec739297b2e7a296483b2
parentf8c9347423d2f860a90d7e055a1c9ddff8cdab32 (diff)
Expand each (media) URL only once. Twitter likes duplication. #1275.
-rw-r--r--protocols/twitter/twitter_lib.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/protocols/twitter/twitter_lib.c b/protocols/twitter/twitter_lib.c
index cd8247c2..96fa8360 100644
--- a/protocols/twitter/twitter_lib.c
+++ b/protocols/twitter/twitter_lib.c
@@ -709,8 +709,7 @@ static void expand_entities(char **text, const json_value *node, const json_valu
if (!((entities = json_o_get(node, "entities")) && entities->type == json_object))
return;
if ((quoted = json_o_get(node, "quoted_status")) && quoted->type == json_object) {
- /* New "retweets with comments" feature. Note that this info
- * seems to be included in the streaming API only! Grab the
+ /* New "retweets with comments" feature. Grab the
* full message and try to insert it when we run into the
* Tweet entity. */
struct twitter_xml_status *txs = twitter_xt_get_status(quoted);
@@ -750,7 +749,10 @@ static void expand_entities(char **text, const json_value *node, const json_valu
const char *full = json_o_str(v->u.array.values[i], "expanded_url");
char *pos, *new;
- if (!kort || !disp || !(pos = strstr(*text, kort))) {
+ /* Skip if a required field is missing, if the t.co URL is not in fact
+ in the Tweet at all, or if the full-ish one *is* in it already
+ (dupes appear, especially in streaming API). */
+ if (!kort || !disp || !(pos = strstr(*text, kort)) || strstr(*text, disp)) {
continue;
}
if (quote_url && strstr(full, quote_url)) {