Skip to content

Commit d2286a9

Browse files
committed
Allow embedded spaces without quoting in unix_socket_directories entries.
This fix removes an unnecessary incompatibility with the old behavior of the unix_socket_directory parameter. Since pathnames with embedded spaces are fairly popular on some platforms, the incompatibility could be significant in practice. We'll still strip unquoted leading/trailing spaces, however. No docs update since the documentation already implied that it worked like this. Per bug #7514 from Murray Cumming.
1 parent 25f4fe4 commit d2286a9

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/backend/utils/adt/varlena.c

+12-9
Original file line numberDiff line numberDiff line change
@@ -2451,9 +2451,9 @@ SplitIdentifierString(char *rawstring, char separator,
24512451
*
24522452
* This is similar to SplitIdentifierString, except that the parsing
24532453
* rules are meant to handle pathnames instead of identifiers: there is
2454-
* no downcasing, the max length is MAXPGPATH-1, and we apply
2455-
* canonicalize_path() to each extracted string. Because of the last,
2456-
* the returned strings are separately palloc'd rather than being
2454+
* no downcasing, embedded spaces are allowed, the max length is MAXPGPATH-1,
2455+
* and we apply canonicalize_path() to each extracted string. Because of the
2456+
* last, the returned strings are separately palloc'd rather than being
24572457
* pointers into rawstring --- but we still scribble on rawstring.
24582458
*
24592459
* Inputs:
@@ -2510,13 +2510,16 @@ SplitDirectoriesString(char *rawstring, char separator,
25102510
}
25112511
else
25122512
{
2513-
/* Unquoted name --- extends to separator or whitespace */
2514-
curname = nextp;
2515-
while (*nextp && *nextp != separator &&
2516-
!isspace((unsigned char) *nextp))
2513+
/* Unquoted name --- extends to separator or end of string */
2514+
curname = endp = nextp;
2515+
while (*nextp && *nextp != separator)
2516+
{
2517+
/* trailing whitespace should not be included in name */
2518+
if (!isspace((unsigned char) *nextp))
2519+
endp = nextp + 1;
25172520
nextp++;
2518-
endp = nextp;
2519-
if (curname == nextp)
2521+
}
2522+
if (curname == endp)
25202523
return false; /* empty unquoted name not allowed */
25212524
}
25222525

0 commit comments

Comments
 (0)