summaryrefslogtreecommitdiff
path: root/html.c
diff options
context:
space:
mode:
authorGravatar Alex Schroeder2022-12-07 21:55:39 +0100
committerGravatar Alex Schroeder2022-12-07 22:03:32 +0100
commit4c996c76228eff139a879e57c9a2c3b7bc54e101 (patch)
tree55e4fdaf89c77e2d8f73b436d73f43fae3d3b2c4 /html.c
parentAsk for just 1 more entry beyond the current page to test if there are more. (diff)
downloadsnac2-4c996c76228eff139a879e57c9a2c3b7bc54e101.tar.gz
snac2-4c996c76228eff139a879e57c9a2c3b7bc54e101.tar.xz
snac2-4c996c76228eff139a879e57c9a2c3b7bc54e101.zip
Fix mentions with one @ sign
In a mention like the following, the old code had a problem: It would split the name by '@' and get a list of two elements. Since this is less than three, it would then try to get the domain name from the href ("social.alexschroeder.ch") and concatenate it with the name, resulting in "alex@social.alexschroeder.ch@social.alexschroeder.ch". The reason was that the code expects an initial "@". In that case, splitting "@alex@social.alexschroeder.ch" would result in three elements, and no domain name guessing would happen. If, on the other hand, the name was "@foo" then finding the domain name in the URL and appending it so that you get @foo@domain.name is the correct solution. "tag": [ { "type": "Mention", "href": "https://social.alexschroeder.ch/alex", "name": "alex@social.alexschroeder.ch" } ], The fix consists in prepending an "@" if the name does not start with "@" and leaving the rest of the code unchanged.
Diffstat (limited to 'html.c')
-rw-r--r--html.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/html.c b/html.c
index 9e3412b..de054cb 100644
--- a/html.c
+++ b/html.c
@@ -367,6 +367,7 @@ d_char *build_mentions(snac *snac, char *msg)
367 367
368 if (type && strcmp(type, "Mention") == 0 && 368 if (type && strcmp(type, "Mention") == 0 &&
369 href && strcmp(href, snac->actor) != 0 && name) { 369 href && strcmp(href, snac->actor) != 0 && name) {
370 if (name[0] != '@') name = xs_str_cat(xs_str_new("@"), name);
370 xs *l = xs_split(name, "@"); 371 xs *l = xs_split(name, "@");
371 372
372 /* is it a name without a host? */ 373 /* is it a name without a host? */