Changeset 58d285a


Ignore:
Timestamp:
2016-10-03T00:56:35Z (8 years ago)
Author:
dequis <dx@…>
Branches:
master
Children:
01d56c0
Parents:
82e55d2
Message:

twitter: fix quoted tweet expansion in extended tweets

The outermost entities object only contains the url of the compat tweet,
the one linking to /i/web/status/[...]

The inner entities object, inside the "extended_tweet", is the one that
contains the quoted tweet url that we're supposed to replace.

But expand_entities() assumed that the quoted_status object would be
next to entities, which doesn't apply in the case of extended tweets.
So now it gets an extra parameter to look for entities.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/twitter/twitter_lib.c

    r82e55d2 r58d285a  
    587587#endif
    588588
    589 static void expand_entities(char **text, const json_value *node);
     589static void expand_entities(char **text, const json_value *node, const json_value *extended_node);
    590590
    591591/**
     
    602602        const json_value *rt = NULL;
    603603        const json_value *text_value = NULL;
     604        const json_value *extended_node = NULL;
    604605
    605606        if (node->type != json_object) {
     
    615616                } else if (strcmp("extended_tweet", k) == 0 && v->type == json_object) {
    616617                        text_value = json_o_get(v, "full_text");
     618                        extended_node = v;
    617619                } else if (strcmp("retweeted_status", k) == 0 && v->type == json_object) {
    618620                        rt = v;
     
    647649                txs->text = g_memdup(text_value->u.string.ptr, text_value->u.string.length + 1);
    648650                strip_html(txs->text);
    649                 expand_entities(&txs->text, node);
     651                expand_entities(&txs->text, node, extended_node);
    650652        }
    651653
     
    690692        }
    691693
    692         expand_entities(&txs->text, node);
     694        expand_entities(&txs->text, node, NULL);
    693695
    694696        if (txs->text && txs->user && txs->id) {
     
    700702}
    701703
    702 static void expand_entities(char **text, const json_value *node)
    703 {
    704         json_value *entities, *quoted;
     704static void expand_entities(char **text, const json_value *node, const json_value *extended_node)
     705{
     706        json_value *entities, *extended_entities, *quoted;
    705707        char *quote_url = NULL, *quote_text = NULL;
    706708
     
    718720        } else {
    719721                quoted = NULL;
     722        }
     723
     724        if (extended_node) {
     725                extended_entities = json_o_get(extended_node, "entities");
     726                if (extended_entities && extended_entities->type == json_object) {
     727                        entities = extended_entities;
     728                }
    720729        }
    721730
Note: See TracChangeset for help on using the changeset viewer.