From ee3533e420d544ada765a553cf400e96f3b1835d Mon Sep 17 00:00:00 2001 From: Nishi Date: Wed, 11 Sep 2024 15:58:08 +0000 Subject: [PATCH] html escape git-svn-id: file:///raid/svn-personal/keine/trunk@9 a3977ea8-0dc0-2842-9144-a1a46b47fd40 --- CGI/man.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/CGI/man.c b/CGI/man.c index 7e3df56..61bf4ec 100644 --- a/CGI/man.c +++ b/CGI/man.c @@ -63,6 +63,8 @@ bool kn_has_manpage(const char* str) { return true; } +#define HTML(buf) (buf[0] == '<' ? "<" : (buf[0] == '>' ? ">" : (buf[0] == '&' ? "&" : buf))) + char* kn_manpage_process(const char* path) { char* b = malloc(1); b[0] = 0; @@ -107,7 +109,7 @@ char* kn_manpage_process(const char* path) { m = 0; cbuf[0] = s; tmp = b; - b = kn_strcat(b, cbuf); + b = kn_strcat(b, HTML(cbuf)); free(tmp); } else { if(old == s) { @@ -125,7 +127,7 @@ char* kn_manpage_process(const char* path) { } m = 'B'; tmp = b; - b = kn_strcat(b, cbuf); + b = kn_strcat(b, HTML(cbuf)); free(tmp); } else if(old == '_') { cbuf[0] = s; @@ -141,7 +143,7 @@ char* kn_manpage_process(const char* path) { free(tmp); } tmp = b; - b = kn_strcat(b, cbuf); + b = kn_strcat(b, HTML(cbuf)); free(tmp); tmp = b; b = kn_strcat(b, ""); -- 2.43.0