Fix to quote directive values containing #
Some checks failed
Tests / prove (push) Has been cancelled
Package and upload artifacts / build (push) Has been cancelled
Close inactive / close-inactive (push) Has been cancelled

ⓘ Values with a # were written unquoted, so on the next read the module took the # as the start of a comment and lost the rest of the line.

For example, a redirect saved as return 301 https://example.com/docs#install; then showed as no redirect on the page, and re-saving it added a duplicate rewrite_log directive that Nginx rejected.

So, before the fix, saving a redirect to https://example.com/docs#install wrote:

return 301 https://example.com/docs#install;
rewrite_log off;

On the next read the module dropped everything after the #, so it saw one merged line:

return 301 https://example.com/docs rewrite_log off;

The redirect disappeared from the page, and saving again appended a second rewrite_log off;, which Nginx rejects as a duplicate.

After the fix the same save writes:

return 301 "https://example.com/docs#install";
rewrite_log off;

Nginx treats the quoted and unquoted forms identically, and the module reads it back correctly.
This commit is contained in:
Ilia Ross
2026-09-07 03:55:19 +02:00
parent 89a01303c0
commit 78e0f31899

View File

@@ -731,13 +731,15 @@ sub join_words
{
my @rv;
foreach my $w (@_) {
# Quote words with spaces, separators, variables or a # comment marker
my $quote = $w =~ /\s|;|\$/ && $w !~ /^\$/ || $w =~ /#/;
if ($w eq "") {
push(@rv, '""');
}
elsif ($w =~ /\s|;|\$/ && $w !~ /"/ && $w !~ /^\$/) {
elsif ($quote && $w !~ /"/) {
push(@rv, "\"$w\"");
}
elsif ($w =~ /\s|;|\$/ && $w !~ /^\$/) {
elsif ($quote) {
push(@rv, "'$w'");
}
else {