]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Add libhtml.la for HTML syntax tools (#1306)
authorAmos Jeffries <yadij@users.noreply.github.com>
Tue, 17 Oct 2023 20:36:05 +0000 (20:36 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Tue, 17 Oct 2023 23:03:53 +0000 (23:03 +0000)
configure.ac
lib/Makefile.am
src/Makefile.am
src/clients/FtpGateway.cc
src/errorpage.cc
src/html/Makefile.am [new file with mode: 0644]
src/html/Quoting.cc [moved from lib/html_quote.c with 93% similarity]
src/html/Quoting.h [moved from include/html_quote.h with 68% similarity]
src/security/ErrorDetail.cc
tools/Makefile.am
tools/cachemgr.cc

index 05cc1af3a29f116df98fe56d193ca2c3b57c6c02..44c5b88a32062abc9cdde62df3655087f9ec7625 100644 (file)
@@ -3056,6 +3056,7 @@ AC_CONFIG_FILES([
        src/fs/Makefile
        src/ftp/Makefile
        src/helper/Makefile
+       src/html/Makefile
        src/http/Makefile
        src/http/one/Makefile
        src/http/url_rewriters/Makefile
index 77e6f48bf729acb719d5e1c6717d9c8889ad068d..de71e04379d8c35182eea8d36a1b3d4bd4e0ae6c 100644 (file)
@@ -46,7 +46,6 @@ EXTRA_libmiscutil_la_SOURCES = \
 
 libmiscencoding_la_SOURCES = \
        base64.c \
-       html_quote.c \
        md5.c \
        rfc1738.c \
        rfc2617.c
index 81e888748bc64f1746ea87994170347099f8ad04..d9857b6762dccb4fe4d56ff482d91d153caf6d73 100644 (file)
@@ -16,7 +16,7 @@ LOADABLE_MODULES_SOURCES = \
        LoadableModules.cc \
        LoadableModules.h
 
-SUBDIRS = mem time debug base anyp helper dns ftp parser comm error eui acl format clients sbuf servers fs repl store DiskIO proxyp
+SUBDIRS = mem time debug base anyp helper dns html ftp parser comm error eui acl format clients sbuf servers fs repl store DiskIO proxyp
 
 if ENABLE_AUTH
 SUBDIRS += auth
@@ -518,6 +518,7 @@ squid_LDADD = \
        $(REGEXLIB) \
        $(ADAPTATION_LIBS) \
        $(ESI_LIBS) \
+       html/libhtml.la \
        $(SNMP_LIBS) \
        mem/libmem.la \
        store/libstore.la \
@@ -1945,6 +1946,7 @@ tests_test_http_range_LDADD = \
        dns/libdns.la \
        base/libbase.la \
        mgr/libmgr.la \
+       html/libhtml.la \
        sbuf/libsbuf.la \
        debug/libdebug.la \
        store/libstore.la \
@@ -2321,6 +2323,7 @@ tests_testHttpRequest_LDADD = \
        dns/libdns.la \
        base/libbase.la \
        mgr/libmgr.la \
+       html/libhtml.la \
        anyp/libanyp.la \
        $(SNMP_LIBS) \
        icmp/libicmp.la \
@@ -2624,6 +2627,7 @@ tests_testCacheManager_LDADD = \
        anyp/libanyp.la \
        ipc/libipc.la \
        mgr/libmgr.la \
+       html/libhtml.la \
        $(SNMP_LIBS) \
        mem/libmem.la \
        store/libstore.la \
index c3c7b21d0720cd4ed171ae516cf13f4392ec76cb..e04f3624f01d8835ce4aa9c806ac31f8000e89bc 100644 (file)
@@ -23,7 +23,7 @@
 #include "fd.h"
 #include "fde.h"
 #include "FwdState.h"
-#include "html_quote.h"
+#include "html/Quoting.h"
 #include "HttpHdrContRange.h"
 #include "HttpHeader.h"
 #include "HttpHeaderRange.h"
index 6a46b7116f539291963da13af21aab9cebb9108b..5dd96beaf5e374d48573ce189963e1b02c421fde 100644 (file)
@@ -20,7 +20,7 @@
 #include "fde.h"
 #include "format/Format.h"
 #include "fs_io.h"
-#include "html_quote.h"
+#include "html/Quoting.h"
 #include "HttpHeaderTools.h"
 #include "HttpReply.h"
 #include "HttpRequest.h"
diff --git a/src/html/Makefile.am b/src/html/Makefile.am
new file mode 100644 (file)
index 0000000..df90147
--- /dev/null
@@ -0,0 +1,15 @@
+## Copyright (C) 1996-2023 The Squid Software Foundation and contributors
+##
+## Squid software is distributed under GPLv2+ license and includes
+## contributions from numerous individuals and organizations.
+## Please see the COPYING and CONTRIBUTORS files for details.
+##
+
+include $(top_srcdir)/src/Common.am
+include $(top_srcdir)/src/TestHeaders.am
+
+noinst_LTLIBRARIES = libhtml.la
+
+libhtml_la_SOURCES = \
+       Quoting.cc \
+       Quoting.h
similarity index 93%
rename from lib/html_quote.c
rename to src/html/Quoting.cc
index 8b93b45a2f5da24c307105b536c925cd78d45056..d9e0a0bee614b9a897eb465ee519746489388077 100644 (file)
@@ -7,11 +7,7 @@
  */
 
 #include "squid.h"
-#include "html_quote.h"
-
-#if HAVE_STRING_H
-#include <string.h>
-#endif
+#include "html/Quoting.h"
 
 /*
  *  HTML defines these characters as special entities that should be quoted.
@@ -52,7 +48,7 @@ static struct {
 char *
 html_quote(const char *string)
 {
-    static char *buf;
+    static char *buf = nullptr;
     static size_t bufsize = 0;
     const char *src;
     char *dst;
@@ -61,10 +57,10 @@ html_quote(const char *string)
     /* XXX This really should be implemented using a MemPool, but
      * MemPools are not yet available in lib...
      */
-    if (buf == NULL || strlen(string) * 6 > bufsize) {
+    if (!buf || strlen(string) * 6 > bufsize) {
         xfree(buf);
         bufsize = strlen(string) * 6 + 1;
-        buf = xcalloc(bufsize, 1);
+        buf = static_cast<char *>(xcalloc(bufsize, 1));
     }
     for (src = string, dst = buf; *src; src++) {
         const char *escape = NULL;
similarity index 68%
rename from include/html_quote.h
rename to src/html/Quoting.h
index 13b8b6841a6459509857ca65a9e6c005b0aff91b..14d85cd4a786edb1db24221f9549df9c2ff4a4c6 100644 (file)
@@ -6,16 +6,10 @@
  * Please see the COPYING and CONTRIBUTORS files for details.
  */
 
-#ifndef _SQUID_HTML_QUOTE_H
-#define _SQUID_HTML_QUOTE_H
-
-#ifdef __cplusplus
-extern "C"
-#else
-extern
-#endif
+#ifndef SQUID__SRC_HTML_QUOTING_H
+#define SQUID__SRC_HTML_QUOTING_H
 
 char *html_quote(const char *);
 
-#endif /* _SQUID_HTML_QUOTE_H */
+#endif /* SQUID__SRC_HTML_QUOTING_H */
 
index 464bd2832aad2525447eb145082e3b270ba17b4c..162981525688ba4afa8071d23aaf11134be26369 100644 (file)
@@ -9,7 +9,7 @@
 #include "squid.h"
 #include "base/IoManip.h"
 #include "error/SysErrorDetail.h"
-#include "html_quote.h"
+#include "html/Quoting.h"
 #include "sbuf/SBuf.h"
 #include "sbuf/Stream.h"
 #include "security/Certificate.h"
index 2b3309b39861a8c102ae7cdca6cc4ced8c452556..155fa9dcea501b1743a6dc52ec31677acba4d133 100644 (file)
@@ -16,6 +16,7 @@ man_MANS=
 DISTCLEANFILES=
 
 LDADD= \
+       $(top_builddir)/src/html/libhtml.la \
        $(top_builddir)/src/ip/libip.la \
        $(top_builddir)/src/mem/libminimal.la \
        $(top_builddir)/src/time/libtime.la \
index 1008afc38ccc04a88c7182be090aa7e5a1f1e597..928c59e1afd79be805d6ed6bdddd3bfbb66ea93a 100644 (file)
@@ -10,7 +10,7 @@
 #include "base/CharacterSet.h"
 #include "base64.h"
 #include "getfullhostname.h"
-#include "html_quote.h"
+#include "html/Quoting.h"
 #include "ip/Address.h"
 #include "MemBuf.h"
 #include "rfc1738.h"