mirror of
https://gitea.psi.ch/ELOG/elog.git
synced 2026-09-16 21:26:27 +00:00
Use absolute links for inline images in email notifications
SVN revision: 2044
This commit is contained in:
parent
6734ebeeb0
commit
21360ec3d1
26
src/elogd.c
26
src/elogd.c
@ -5531,9 +5531,9 @@ void insert_breaks(char *str, int n, int size)
|
|||||||
|
|
||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
|
|
||||||
void replace_inline_img(char *str)
|
void replace_inline_img(LOGBOOK *lbs, char *str)
|
||||||
{
|
{
|
||||||
char *p, *pn;
|
char *p, *pn, *pa, old[256], link[256], base_url[256];
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
p = str;
|
p = str;
|
||||||
@ -5550,6 +5550,26 @@ void replace_inline_img(char *str)
|
|||||||
pn++;
|
pn++;
|
||||||
sprintf(p, "<img src=\"cid:att%d@psi.ch\">", index);
|
sprintf(p, "<img src=\"cid:att%d@psi.ch\">", index);
|
||||||
memmove(p + strlen(p), pn, strlen(pn) + 1);
|
memmove(p + strlen(p), pn, strlen(pn) + 1);
|
||||||
|
|
||||||
|
/* now change href to absolute link */
|
||||||
|
pa = p - 1;
|
||||||
|
while (pa > str && *pa != '<') // search '<a href=...>'
|
||||||
|
pa--;
|
||||||
|
pn = strstr(pa, "href=");
|
||||||
|
if (pn && pn - pa < 10) {
|
||||||
|
strlcpy(old, pn+6, sizeof(old));
|
||||||
|
if (strchr(old, '\"'))
|
||||||
|
*strchr(old, '\"') = 0;
|
||||||
|
compose_base_url(lbs, base_url, sizeof(base_url), FALSE);
|
||||||
|
strlcpy(link, base_url, sizeof(link));
|
||||||
|
strlcat(link, old, sizeof(link));
|
||||||
|
if (strchr(link, '?'))
|
||||||
|
*strchr(link, '?') = 0;
|
||||||
|
strsubst(pn+6, TEXT_SIZE, old, link);
|
||||||
|
if (strlen(link) > strlen(old))
|
||||||
|
p += strlen(link) - strlen(old);
|
||||||
|
}
|
||||||
|
|
||||||
p++;
|
p++;
|
||||||
} else
|
} else
|
||||||
p++;
|
p++;
|
||||||
@ -23171,7 +23191,7 @@ void show_elog_entry(LOGBOOK * lbs, char *dec_path, char *command)
|
|||||||
rsputs_elcode(lbs, email, text);
|
rsputs_elcode(lbs, email, text);
|
||||||
else {
|
else {
|
||||||
if (email)
|
if (email)
|
||||||
replace_inline_img(text);
|
replace_inline_img(lbs, text);
|
||||||
rsputs(text);
|
rsputs(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user