Fixed processing of URLs with two @ inside.

This commit is contained in:
default 2024-11-03 15:13:31 +01:00
parent 6501187c74
commit a5942432bf

View file

@ -135,7 +135,9 @@ static xs_str *format_line(const char *line, xs_list **attach)
else else
if (*v == '[') { if (*v == '[') {
/* markdown-like links [label](url) */ /* markdown-like links [label](url) */
xs *w = xs_strip_chars_i(xs_replace(v, "#", "#"), "[)"); xs *w = xs_strip_chars_i(
xs_replace_i(xs_replace(v, "#", "#"), "@", "@"),
"![)");
xs *l = xs_split_n(w, "](", 1); xs *l = xs_split_n(w, "](", 1);
if (xs_list_len(l) == 2) { if (xs_list_len(l) == 2) {
@ -150,7 +152,9 @@ static xs_str *format_line(const char *line, xs_list **attach)
else else
if (*v == '!') { if (*v == '!') {
/* markdown-like images ![alt text](url to image) */ /* markdown-like images ![alt text](url to image) */
xs *w = xs_strip_chars_i(xs_replace(v, "#", "#"), "![)"); xs *w = xs_strip_chars_i(
xs_replace_i(xs_replace(v, "#", "#"), "@", "@"),
"![)");
xs *l = xs_split_n(w, "](", 1); xs *l = xs_split_n(w, "](", 1);
if (xs_list_len(l) == 2) { if (xs_list_len(l) == 2) {
@ -179,7 +183,8 @@ static xs_str *format_line(const char *line, xs_list **attach)
} }
else else
if (xs_str_in(v, ":/" "/") != -1) { if (xs_str_in(v, ":/" "/") != -1) {
xs *u = xs_replace(v, "#", "#"); xs *u = xs_replace_i(xs_replace(v, "#", "#"), "@", "@");
xs *v2 = xs_strip_chars_i(xs_dup(u), ".,)"); xs *v2 = xs_strip_chars_i(xs_dup(u), ".,)");
const char *mime = xs_mime_by_ext(v2); const char *mime = xs_mime_by_ext(v2);