From: Amos Jeffries Date: Tue, 17 Oct 2023 20:36:05 +0000 (+0000) Subject: Add libhtml.la for HTML syntax tools (#1306) X-Git-Tag: SQUID_7_0_1~326 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1d0bc8e;p=thirdparty%2Fsquid.git Add libhtml.la for HTML syntax tools (#1306) --- diff --git a/configure.ac b/configure.ac index 05cc1af3a2..44c5b88a32 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/lib/Makefile.am b/lib/Makefile.am index 77e6f48bf7..de71e04379 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -46,7 +46,6 @@ EXTRA_libmiscutil_la_SOURCES = \ libmiscencoding_la_SOURCES = \ base64.c \ - html_quote.c \ md5.c \ rfc1738.c \ rfc2617.c diff --git a/src/Makefile.am b/src/Makefile.am index 81e888748b..d9857b6762 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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 \ diff --git a/src/clients/FtpGateway.cc b/src/clients/FtpGateway.cc index c3c7b21d07..e04f3624f0 100644 --- a/src/clients/FtpGateway.cc +++ b/src/clients/FtpGateway.cc @@ -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" diff --git a/src/errorpage.cc b/src/errorpage.cc index 6a46b7116f..5dd96beaf5 100644 --- a/src/errorpage.cc +++ b/src/errorpage.cc @@ -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 index 0000000000..df90147261 --- /dev/null +++ b/src/html/Makefile.am @@ -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 diff --git a/lib/html_quote.c b/src/html/Quoting.cc similarity index 93% rename from lib/html_quote.c rename to src/html/Quoting.cc index 8b93b45a2f..d9e0a0bee6 100644 --- a/lib/html_quote.c +++ b/src/html/Quoting.cc @@ -7,11 +7,7 @@ */ #include "squid.h" -#include "html_quote.h" - -#if HAVE_STRING_H -#include -#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(xcalloc(bufsize, 1)); } for (src = string, dst = buf; *src; src++) { const char *escape = NULL; diff --git a/include/html_quote.h b/src/html/Quoting.h similarity index 68% rename from include/html_quote.h rename to src/html/Quoting.h index 13b8b6841a..14d85cd4a7 100644 --- a/include/html_quote.h +++ b/src/html/Quoting.h @@ -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 */ diff --git a/src/security/ErrorDetail.cc b/src/security/ErrorDetail.cc index 464bd2832a..1629815256 100644 --- a/src/security/ErrorDetail.cc +++ b/src/security/ErrorDetail.cc @@ -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" diff --git a/tools/Makefile.am b/tools/Makefile.am index 2b3309b398..155fa9dcea 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -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 \ diff --git a/tools/cachemgr.cc b/tools/cachemgr.cc index 1008afc38c..928c59e1af 100644 --- a/tools/cachemgr.cc +++ b/tools/cachemgr.cc @@ -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"