diff options
Diffstat (limited to '')
| -rw-r--r-- | utils.c | 27 |
1 files changed, 25 insertions, 2 deletions
| @@ -446,7 +446,8 @@ int deluser(snac *user) | |||
| 446 | void verify_links(snac *user) | 446 | void verify_links(snac *user) |
| 447 | /* verifies a user's links */ | 447 | /* verifies a user's links */ |
| 448 | { | 448 | { |
| 449 | const xs_dict *p = xs_dict_get(user->config, "metadata"); | 449 | xs *metadata = NULL; |
| 450 | const xs_dict *md = xs_dict_get(user->config, "metadata"); | ||
| 450 | const char *k, *v; | 451 | const char *k, *v; |
| 451 | int changed = 0; | 452 | int changed = 0; |
| 452 | 453 | ||
| @@ -454,8 +455,30 @@ void verify_links(snac *user) | |||
| 454 | headers = xs_dict_append(headers, "accept", "text/html"); | 455 | headers = xs_dict_append(headers, "accept", "text/html"); |
| 455 | headers = xs_dict_append(headers, "user-agent", USER_AGENT " (link verify)"); | 456 | headers = xs_dict_append(headers, "user-agent", USER_AGENT " (link verify)"); |
| 456 | 457 | ||
| 458 | if (xs_type(md) == XSTYPE_DICT) | ||
| 459 | metadata = xs_dup(md); | ||
| 460 | else | ||
| 461 | if (xs_type(md) == XSTYPE_STRING) { | ||
| 462 | /* convert to dict for easier iteration */ | ||
| 463 | metadata = xs_dict_new(); | ||
| 464 | xs *l = xs_split(md, "\n"); | ||
| 465 | const char *ll; | ||
| 466 | |||
| 467 | xs_list_foreach(l, ll) { | ||
| 468 | xs *kv = xs_split_n(ll, "=", 1); | ||
| 469 | const char *k = xs_list_get(kv, 0); | ||
| 470 | const char *v = xs_list_get(kv, 1); | ||
| 471 | |||
| 472 | if (k && v) { | ||
| 473 | xs *kk = xs_strip_i(xs_dup(k)); | ||
| 474 | xs *vv = xs_strip_i(xs_dup(v)); | ||
| 475 | metadata = xs_dict_set(metadata, kk, vv); | ||
| 476 | } | ||
| 477 | } | ||
| 478 | } | ||
| 479 | |||
| 457 | int c = 0; | 480 | int c = 0; |
| 458 | while (p && xs_dict_next(p, &k, &v, &c)) { | 481 | while (metadata && xs_dict_next(metadata, &k, &v, &c)) { |
| 459 | /* not an https link? skip */ | 482 | /* not an https link? skip */ |
| 460 | if (!xs_startswith(v, "https:/" "/")) | 483 | if (!xs_startswith(v, "https:/" "/")) |
| 461 | continue; | 484 | continue; |