commit - 6e8f426eff55c3ebcd1977185da46975fac2d1ad
commit + 33f4bf26d1b76c691875b3ced0aa267928a0a2f6
blob - ad9bf9566285410e6fa897bcbd8566785c4b230e
blob + 5efa7d8b12a5fc18c1221efcdf8b2933b5997663
--- proxy.c
+++ proxy.c
#include <ctype.h>
#include <errno.h>
#include <event.h>
+#include <fnmatch.h>
#include <limits.h>
#include <stdlib.h>
#include <stdint.h>
if (!strncmp(line, "=>", 2)) {
char *label;
- if (!(clt->clt_translate & TR_NAV)) {
- if (clt_puts(clt, "<nav><ul>") == -1)
- return (-1);
- clt->clt_translate |= TR_NAV;
- }
-
line += 2;
line += strspn(line, " \t");
else
*label++ = '\0';
+ if (fnmatch("*.jpg", line, 0) == 0 ||
+ fnmatch("*.jpeg", line, 0) == 0 ||
+ fnmatch("*.gif", line, 0) == 0 ||
+ fnmatch("*.png", line, 0) == 0 ||
+ fnmatch("*.svg", line, 0) == 0 ||
+ fnmatch("*.webp", line, 0) == 0) {
+ if (clt->clt_translate & TR_NAV) {
+ if (clt_puts(clt, "</ul></nav>") == -1)
+ return (-1);
+ clt->clt_translate &= ~TR_NAV;
+ }
+
+ if (clt_puts(clt, "<figure><a href='") == -1 ||
+ printurl(clt, line) == -1 ||
+ clt_puts(clt, "'><img src='") == -1 ||
+ printurl(clt, line) == -1 ||
+ clt_puts(clt, "' /></a><figcaption>") == -1 ||
+ htmlescape(clt, label) == -1 ||
+ clt_puts(clt, "</figcaption></figure>") == -1)
+ return (-1);
+
+ return (0);
+ }
+
+ if (!(clt->clt_translate & TR_NAV)) {
+ if (clt_puts(clt, "<nav><ul>") == -1)
+ return (-1);
+ clt->clt_translate |= TR_NAV;
+ }
+
if (clt_puts(clt, "<li><a href='") == -1 ||
printurl(clt, line) == -1 ||
clt_puts(clt, "'>") == -1 ||