Discard malformed inbox bodies, make system messages non-sensitive, handle :: correctly as normal text and not emoji

master
teknomunk 1 year ago
parent 142c8e451e
commit 65ac539466

@ -540,6 +540,13 @@ static bool process_one()
goto discard;
}
// Malformed body
printf( "Body: ->|%s|<-\n", env->body );
if( !env->body || !*env->body || ( 0 == strncmp("null",env->body,4) ) ) {
printf( "Malformed body, discarding\n" );
goto discard;
}
// Load activity
FILE* f = fmemopen( env->body, strlen(env->body), "r" );
act = ap_object_from_FILE(f);

@ -1 +1 @@
Subproject commit c8d14e2ba30c3536911c31f5db935a269f179ba0
Subproject commit bcf56bd05285acca6f8da6be2714893a976ef8c6

@ -484,7 +484,6 @@ struct status* status_new_system_unfollow( int account_id )
s->published = time(NULL);
s->account_id = -1;
asprintf( &s->content, "%s unfollowed you\n", a->display_name );
s->sensitive = true;
account_free(a);
@ -503,7 +502,6 @@ struct status* status_new_system_block( int account_id )
s->published = time(NULL);
s->account_id = -1;
asprintf( &s->content, "%s blocked you. View their account <a href='%s'>here</a>.", a->display_name, a->account_url );
s->sensitive = false;
account_free(a);
@ -522,7 +520,6 @@ struct status* status_new_system_stub( struct status* stub )
stub->id,
stub->url, stub->url
);
s->sensitive = false;
return s;
}

@ -87,19 +87,23 @@ char* status_render_source( struct status* s )
char* shortcode = strndup( start, i - start );
// Check if shortcode is already present in status
for( int i = 0; i < s->emoji.count; ++i ) {
struct emoji* e = s->emoji.items[i];
if( 0 == strcmp( e->shortcode, shortcode ) ) { goto already_has_emoji; }
}
if( !*shortcode ) {
fprintf( f, ":" );
} else {
// Check if shortcode is already present in status
for( int i = 0; i < s->emoji.count; ++i ) {
struct emoji* e = s->emoji.items[i];
if( 0 == strcmp( e->shortcode, shortcode ) ) { goto already_has_emoji; }
}
struct emoji* e = emoji_from_shortcode( shortcode );
if( e ) {
array_append( &s->emoji, sizeof(e), &e );
}
struct emoji* e = emoji_from_shortcode( shortcode );
if( e ) {
array_append( &s->emoji, sizeof(e), &e );
}
already_has_emoji:
fprintf( f, ":%s", shortcode );
already_has_emoji:
fprintf( f, ":%s", shortcode );
}
free(shortcode);
} else if( *i == '\n' ) {
fprintf( f, "<br/>" );

Loading…
Cancel
Save