#include "auth/Config.h"
#include "auth/Scheme.h"
#include "AuthReg.h"
+#include "base/CharacterSet.h"
#include "base/PackableStream.h"
#include "base/RunnersRegistry.h"
#include "cache_cf.h"
cfg_filename = file_name;
}
+/// Determines whether the given squid.conf character is a token-delimiting
+/// space character according to squid.conf preprocessor grammar. That grammar
+/// only recognizes two space characters: ASCII SP and HT. Unlike isspace(3),
+/// this function is not sensitive to locale(1) and does not classify LF, VT,
+/// FF, and CR characters as token-delimiting space. However, some squid.conf
+/// directive-specific parsers still define space based on isspace(3).
+static bool
+IsSpace(const char ch)
+{
+ return CharacterSet::WSP[ch];
+}
+
static const char*
skip_ws(const char* s)
{
- while (xisspace(*s))
+ while (IsSpace(*s))
++s;
return s;
{
assert(str != nullptr);
unsigned i = strlen(str);
- while ((i > 0) && xisspace(str[i - 1]))
+ while ((i > 0) && IsSpace(str[i - 1]))
--i;
str[i] = '\0';
}
str += len;
if (*str == '\0')
return str;
- else if (xisspace(*str))
+ else if (IsSpace(*str))
return skip_ws(str);
}
if (file == token)
continue; /* Not a valid #line directive, may be a comment */
- while (*file && xisspace((unsigned char) *file))
+ while (*file && IsSpace(*file))
++file;
if (*file) {
fatalf("'else' without 'if'\n");
} else if (if_states.empty() || if_states.back()) { // test last if-statement meaning if present
/* Handle includes here */
- if (tmp_line_len >= 9 && strncmp(tmp_line, "include", 7) == 0 && xisspace(tmp_line[7])) {
+ if (tmp_line_len >= 9 && strncmp(tmp_line, "include", 7) == 0 && IsSpace(tmp_line[7])) {
err_count += parseManyConfigFiles(tmp_line + 8, depth + 1);
} else {
try {
"parse_line(char *buff)\n"
"{\n"
"\tchar\t*token;\n"
- "\tif ((token = strtok(buff, w_space)) == NULL) \n"
+ "\tif ((token = strtok(buff, \" \\t\")) == NULL) \n"
"\t\treturn 1;\t/* ignore empty lines */\n"
"\tConfigParser::SetCfgLine(strtok(nullptr, \"\"));\n";
--- /dev/null
+## Copyright (C) 1996-2024 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.
+##
+
+# The following line has leading and trailing SP and HT characters around
+# directive name. The preprocessor is supposed to silently strip them.
+ memory_pools off
+
+# The following line has an ASCII VT character (0x0B) after a recognized
+# directive name. VT character is followed by a regular SP character to
+# make sure preprocessor can isolate (some) directive name.
+http_access\v deny all
+
+# The following line has UTF-8 No-Break Space character (0xC2A0) after a
+# recognized directive name. No SP character follows NBSP to test that
+# preprocessor does not isolate recognized directive names based on their
+# spelling (it should isolate the name token based on spaces instead).
+debug_options ALL,1 2,3
+
+# The following line has UTF-8 Wavy Low Line character (0xEFB98F) instead of
+# the first ASCII underscore in what would otherwise be a recognized directive
+# name. This test validates that preprocessor does not isolate unrecognized
+# directive names based on their spelling (it should isolate the name token
+# based on spaces instead).
+forward﹏max_tries 13