Fix status regex

FossilOrigin-Name: 48b6e79f5035b50bdce1aff46b8cb0eec39fe92ec98609704b8b4905e4e5cf92
This commit is contained in:
nekobit 2022-07-03 04:47:43 +00:00
parent 7f654b7f5c
commit 3f28928a1b
3 changed files with 11 additions and 6 deletions

View file

@ -95,9 +95,9 @@ int main(void)
{ "/lists/edit/:", list_edit },
{ "/lists/for/:", content_tl_list },
{ "/lists", content_lists },
{ "/local", content_tl_local },
{ "/federated", content_tl_federated },
{ "/direct", content_tl_direct },
{ "/local", content_tl_local },
{ "/bookmarks", content_account_bookmarks },
{ "/favourites", content_account_favourites },
{ "/blocked", content_account_blocked },

View file

@ -499,7 +499,7 @@ char* reformat_status(struct session* ssn,
return res;
}
#define REGEX_MENTION "<a .*?mention.*?href=\"https?:\\/\\/(.*?)\\/(?:@|users/)?(.*?)?\".*?>"
#define REGEX_MENTION "(?=<a .*?mention.*?)<a .*?href=\"https?:\\/\\/(.*?)\\/(?:@|users\\/)?(.*?)?\".*?>"
char* make_mentions_local(char* content)
{
@ -512,11 +512,12 @@ char* make_mentions_local(char* content)
size_t res_len = 1024;
char* res = malloc(res_len);
pcre2_code* re = pcre2_compile((PCRE2_SPTR)REGEX_MENTION,
PCRE2_ZERO_TERMINATED, 0,
PCRE2_ZERO_TERMINATED, PCRE2_MULTILINE,
&error, &erroffset, NULL);
if (re == NULL)
{
fprintf(stderr, "Couldn't parse regex at offset %ld: %d\n", erroffset, error);
char* v;
easprintf(&v, "Couldn't parse regex at offset %d: %s\n", error, REGEX_MENTION + erroffset);
pcre2_code_free(re);
return NULL;
}
@ -554,8 +555,12 @@ char* make_mentions_local(char* content)
res = realloc(res, res_len);
break;
default:
{
char buf[256];
pcre2_get_error_message(rc, buf, 256);
goto out;
}
}
}
else
substitute_success = 1;

View file

@ -186,8 +186,8 @@ void tl_public(struct session* ssn, mastodont_t* api, int local, enum base_categ
struct mstdnt_storage storage = { 0 };
struct mstdnt_timeline_args args = {
.with_muted = 1,
.local = local,
.with_muted = MSTDNT_TRUE,
.local = local ? MSTDNT_TRUE : MSTDNT_FALSE,
.remote = 0,
// Converts to `enum mstdnt_reply_visibility' nicely
.reply_visibility = (ssn->post.replies_only.is_set ?