]> Git repositories of Nishi - keine.git/commitdiff
html escape
authorNishi <nishi@nishi.boats>
Wed, 11 Sep 2024 15:58:08 +0000 (15:58 +0000)
committerNishi <nishi@nishi.boats>
Wed, 11 Sep 2024 15:58:08 +0000 (15:58 +0000)
git-svn-id: file:///raid/svn-personal/keine/trunk@9 a3977ea8-0dc0-2842-9144-a1a46b47fd40

CGI/man.c

index 7e3df563594c6f269ff53e111a1afd0d1e62f324..61bf4ecdff8955cb42903a0180ab56a5b54b192c 100644 (file)
--- 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] == '<' ? "&lt;" : (buf[0] == '>' ? "&gt;" : (buf[0] == '&' ? "&amp;" : 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, "</u>");