summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--html.c13
-rw-r--r--utils.c16
2 files changed, 26 insertions, 3 deletions
diff --git a/html.c b/html.c
index 892475c..f5d9aea 100644
--- a/html.c
+++ b/html.c
@@ -1077,10 +1077,17 @@ static xs_html *html_user_body(snac *user, int read_only)
1077 while (xs_dict_next(metadata, &k, &v, &c)) { 1077 while (xs_dict_next(metadata, &k, &v, &c)) {
1078 xs_html *value; 1078 xs_html *value;
1079 1079
1080 if (xs_startswith(v, "https:/") || xs_startswith(v, "http:/")) { 1080 if (xs_startswith(v, "https:/") || xs_startswith(v, "http:/") || *v == '@') {
1081 /* is this link validated? */ 1081 /* is this link validated? */
1082 xs *verified_link = NULL; 1082 xs *verified_link = NULL;
1083 const xs_number *val_time = xs_dict_get(val_links, v); 1083 const xs_number *val_time = xs_dict_get(val_links, v);
1084 const char *url = NULL;
1085
1086 if (xs_is_string(val_time)) {
1087 /* resolve again, as it may be an account handle */
1088 url = val_time;
1089 val_time = xs_dict_get(val_links, val_time);
1090 }
1084 1091
1085 if (xs_type(val_time) == XSTYPE_NUMBER) { 1092 if (xs_type(val_time) == XSTYPE_NUMBER) {
1086 time_t t = xs_number_get(val_time); 1093 time_t t = xs_number_get(val_time);
@@ -1098,13 +1105,13 @@ static xs_html *html_user_body(snac *user, int read_only)
1098 xs_html_tag("a", 1105 xs_html_tag("a",
1099 xs_html_attr("rel", "me"), 1106 xs_html_attr("rel", "me"),
1100 xs_html_attr("target", "_blank"), 1107 xs_html_attr("target", "_blank"),
1101 xs_html_attr("href", v), 1108 xs_html_attr("href", url ? url : v),
1102 xs_html_text(v))); 1109 xs_html_text(v)));
1103 } 1110 }
1104 else { 1111 else {
1105 value = xs_html_tag("a", 1112 value = xs_html_tag("a",
1106 xs_html_attr("rel", "me"), 1113 xs_html_attr("rel", "me"),
1107 xs_html_attr("href", v), 1114 xs_html_attr("href", url ? url : v),
1108 xs_html_text(v)); 1115 xs_html_text(v));
1109 } 1116 }
1110 } 1117 }
diff --git a/utils.c b/utils.c
index d50707a..d8c55dc 100644
--- a/utils.c
+++ b/utils.c
@@ -488,6 +488,18 @@ void verify_links(snac *user)
488 488
489 int c = 0; 489 int c = 0;
490 while (metadata && xs_dict_next(metadata, &k, &v, &c)) { 490 while (metadata && xs_dict_next(metadata, &k, &v, &c)) {
491 xs *wfinger = NULL;
492 const char *ov = NULL;
493
494 /* is it an account handle? */
495 if (*v == '@' && strchr(v + 1, '@')) {
496 /* resolve it via webfinger */
497 if (valid_status(webfinger_request(v, &wfinger, NULL)) && xs_is_string(wfinger)) {
498 ov = v;
499 v = wfinger;
500 }
501 }
502
491 /* not an https link? skip */ 503 /* not an https link? skip */
492 if (!xs_startswith(v, "https:/" "/")) 504 if (!xs_startswith(v, "https:/" "/"))
493 continue; 505 continue;
@@ -563,6 +575,10 @@ void verify_links(snac *user)
563 575
564 user->links = xs_dict_set(user->links, v, verified_time); 576 user->links = xs_dict_set(user->links, v, verified_time);
565 577
578 /* also add the original value if it was 'resolved' */
579 if (xs_is_string(ov))
580 user->links = xs_dict_set(user->links, ov, v);
581
566 vfied = 1; 582 vfied = 1;
567 } 583 }
568 else 584 else