"To hell with cloud. Run Citadel." --Taylor Swift
authorArt Cancro <ajc@citadel.org>
Tue, 30 Jan 2024 19:07:44 +0000 (14:07 -0500)
committerArt Cancro <ajc@citadel.org>
Tue, 30 Jan 2024 19:07:44 +0000 (14:07 -0500)
webcit-ng/server/html2html.c
webcit-ng/server/webcit.h

index 506a70de7fe1b538b800f5b3b2270fe8ad9a8bf4..5a76bc2fc3ca1de59a175802f7b1c7d4af79888c 100644 (file)
@@ -181,10 +181,11 @@ StrBuf *html2html(const char *supplied_charset, int treat_as_wiki, char *roomnam
 
                // Any of these tags cause everything up to and including
                // the tag to be removed.
-               if ((!strncasecmp(ptr, "HTML", 4))
-                   || (!strncasecmp(ptr, "HEAD", 4))
-                   || (!strncasecmp(ptr, "/HEAD", 5))
-                   || (!strncasecmp(ptr, "BODY", 4))) {
+               if (    (!strncasecmp(ptr, "HTML", 4))
+                       || (!strncasecmp(ptr, "HEAD", 4))
+                       || (!strncasecmp(ptr, "/HEAD", 5))
+                       || (!strncasecmp(ptr, "BODY", 4))
+               ) {
                        char *pBody = NULL;
 
                        if (!strncasecmp(ptr, "BODY", 4)) {
@@ -252,10 +253,10 @@ StrBuf *html2html(const char *supplied_charset, int treat_as_wiki, char *roomnam
        converted_msg = NewStrBufPlain(NULL, content_length + 8192);
 
        // Convert foreign character sets to UTF-8 if necessary
-       if ((strcasecmp(charset, "us-ascii"))
-           && (strcasecmp(charset, "UTF-8"))
-           && (strcasecmp(charset, ""))
-           ) {
+       if (    (strcasecmp(charset, "us-ascii"))
+               && (strcasecmp(charset, "UTF-8"))
+               && (strcasecmp(charset, ""))
+       ) {
                syslog(LOG_DEBUG, "Converting %s to UTF-8", charset);
                ctdl_iconv_open("UTF-8", charset, &ic);
                if (ic == (iconv_t) (-1)) {
@@ -341,10 +342,10 @@ StrBuf *html2html(const char *supplied_charset, int treat_as_wiki, char *roomnam
                                ptr = &ptr[8];
                        }
                        else if ((treat_as_wiki)
-                                  && (strncasecmp(ptr, "<a href=\"wiki?", 14))
-                                  && (strncasecmp(ptr, "<a href=\"dotgoto?", 17))
-                                  && (strncasecmp(ptr, "<a href=\"knrooms?", 17))
-                           ) {
+                               && (strncasecmp(ptr, "<a href=\"wiki?", 14))
+                               && (strncasecmp(ptr, "<a href=\"dotgoto?", 17))
+                               && (strncasecmp(ptr, "<a href=\"knrooms?", 17))
+                       ) {
                                content_length += 64;
                                StrBufAppendPrintf(converted_msg, "<a href=\"wiki?go=");
                                //StrBufUrlescAppend(converted_msg, "FIXME ROOM NAME", NULL);                   // FIXME make compatible with webcit-ng
@@ -373,11 +374,12 @@ StrBuf *html2html(const char *supplied_charset, int treat_as_wiki, char *roomnam
                        src = strstr(ptr, "src=\"cid:");
                        ++brak;
 
-                       if (src && isspace(*(src - 1))
-                           && tag_end && (cid_start = strchr(src, ':'))
-                           && (cid_end = strchr(cid_start, '"'))
-                           && (cid_end < tag_end)
-                           ) {
+                       if (    src
+                               && isspace(*(src - 1))
+                               && tag_end && (cid_start = strchr(src, ':'))
+                               && (cid_end = strchr(cid_start, '"'))
+                               && (cid_end < tag_end)
+                       ) {
                                // copy tag and attributes up to src="cid:
                                StrBufAppendBufPlain(converted_msg, ptr, src - ptr, 0);
                                cid_start++;
@@ -405,20 +407,21 @@ StrBuf *html2html(const char *supplied_charset, int treat_as_wiki, char *roomnam
 
                        strlenptr = strlen(ptr);
                        for (i = 0; i <= strlenptr; ++i) {
-                               if ((ptr[i] == 0)
-                                   || (isspace(ptr[i]))
-                                   || (ptr[i] == 10)
-                                   || (ptr[i] == 13)
-                                   || (ptr[i] == '(')
-                                   || (ptr[i] == ')')
-                                   || (ptr[i] == '<')
-                                   || (ptr[i] == '>')
-                                   || (ptr[i] == '[')
-                                   || (ptr[i] == ']')
-                                   || (ptr[i] == '"')
-                                   || (ptr[i] == '\'')
-                                   )
+                               if (    (ptr[i] == 0)
+                                       || (isspace(ptr[i]))
+                                       || (ptr[i] == 10)
+                                       || (ptr[i] == 13)
+                                       || (ptr[i] == '(')
+                                       || (ptr[i] == ')')
+                                       || (ptr[i] == '<')
+                                       || (ptr[i] == '>')
+                                       || (ptr[i] == '[')
+                                       || (ptr[i] == ']')
+                                       || (ptr[i] == '"')
+                                       || (ptr[i] == '\'')
+                               ) {
                                        linklen = i;
+                               }
                                // entity tag?
                                if (ptr[i] == '&') {
                                        if ((ptr[i + 2] == ';') ||
index 3679d245c4fad8583ee58c287be14d0b0ef092bb..54529c83b7e415747e9627b074426975444cc732 100644 (file)
@@ -45,8 +45,8 @@
 //#define DEBUG_HTTP                           // uncomment to debug HTTP headers
 
 // XML_StopParser is present in expat 2.x
-#if XML_MAJOR_VERSION > 1
-#define HAVE_XML_STOPPARSER
+#if XML_MAJOR_VERSION < 2
+#error WebCit requires expat v2.0 or newer.
 #endif
 
 struct client_handle {                         // this gets passed up the stack from the webserver to the application code