Ignore:
Timestamp:
2015-06-17T22:47:26Z (9 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Children:
b441614
Parents:
d832164 (diff), 2f99f23 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge remote-tracking branch 'origin/master' into parson

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/twitter/twitter.c

    rd832164 rb75671d  
    469469        g_regex_match(regex, msg, 0, &match_info);
    470470        while (g_match_info_matches(match_info)) {
    471                 gchar *url = g_match_info_fetch(match_info, 2);
     471                gchar *s, *url;
     472
     473                url = g_match_info_fetch(match_info, 2);
    472474                url_len_diff += target_len - g_utf8_strlen(url, -1);
     475
    473476                /* Add another character for https://t.co/... URLs */
    474                 if (g_match_info_fetch(match_info, 3) != NULL) {
     477                if ((s = g_match_info_fetch(match_info, 3))) {
    475478                        url_len_diff += 1;
     479                        g_free(s);
    476480                }
    477481                g_free(url);
     
    483487}
    484488
    485 static gboolean twitter_length_check(struct im_connection *ic, gchar * msg)
    486 {
    487         int max = set_getint(&ic->acc->set, "message_length"), len;
    488         int target_len = set_getint(&ic->acc->set, "target_url_length");
     489int twitter_message_len(gchar *msg, int target_len)
     490{
    489491        int url_len_diff = 0;
    490492
     
    493495        }
    494496
    495         if (max == 0 || (len = g_utf8_strlen(msg, -1) + url_len_diff) <= max) {
     497        return g_utf8_strlen(msg, -1) + url_len_diff;
     498}
     499
     500static gboolean twitter_length_check(struct im_connection *ic, gchar * msg)
     501{
     502        int max = set_getint(&ic->acc->set, "message_length");
     503        int target_len = set_getint(&ic->acc->set, "target_url_length");
     504        int len = twitter_message_len(msg, target_len);
     505
     506        if (max == 0 || len <= max) {
    496507                return TRUE;
    497508        }
     
    852863}
    853864
    854 /* Parses a decimal or hex tweet ID, returns TRUE on success */
    855 static gboolean twitter_parse_id(char *string, int base, guint64 *id)
    856 {
    857         guint64 parsed;
    858         char *endptr;
    859 
    860         errno = 0;
    861         parsed = g_ascii_strtoull(string, &endptr, base);
    862         if (errno || endptr == string || *endptr != '\0') {
    863                 return FALSE;
    864         }
    865         *id = parsed;
    866         return TRUE;
    867 }
    868 
    869865bee_user_t twitter_log_local_user;
    870866
     
    896892                        arg++;
    897893                }
    898                 if (twitter_parse_id(arg, 16, &id) && id < TWITTER_LOG_LENGTH) {
     894                if (parse_int64(arg, 16, &id) && id < TWITTER_LOG_LENGTH) {
    899895                        bu = td->log[id].bu;
    900896                        id = td->log[id].id;
    901                 } else if (twitter_parse_id(arg, 10, &id)) {
     897                } else if (parse_int64(arg, 10, &id)) {
    902898                        /* Allow normal tweet IDs as well; not a very useful
    903899                           feature but it's always been there. Just ignore
     
    10161012                        twitter_log(ic, "Tweet `%s' does not exist", cmd[1]);
    10171013                } else {
    1018                         /* More common link is twitter.com/$UID/status/$ID (and that's
    1019                          * what this will 302 to) but can't generate that since for RTs,
    1020                          * bu here points at the retweeter while id contains the id of
    1021                          * the original message. */
    1022                         twitter_log(ic, "https://twitter.com/statuses/%lld", id);
     1014                        twitter_status_show_url(ic, id);
    10231015                }
    10241016                goto eof;
Note: See TracChangeset for help on using the changeset viewer.