fix: consistent section header detection in listen extraction

Additional fix for listen block extraction:
- Section boundary check now uses ([[:space:]]|$) pattern
- Previously only checked [[:space:]], missing 'defaults' at end of line
- Ensures listen extraction stops correctly at any section header

Pattern consistency verified across all 4 locations:
- Linux install mode: global, defaults, listen extraction ✓
- Linux daemon mode: global, defaults, listen extraction ✓
- macOS install mode: global, defaults, listen extraction ✓
- macOS daemon mode: global, defaults, listen extraction ✓

Edge cases tested:
- Named defaults (defaults http): works correctly
- Multiple listen blocks: all preserved
- Tab characters: handled by [[:space:]]
- User's actual config structure: produces clean merge

No impact on other agent functions (self-upgrade, metrics, etc.)
This commit is contained in:
taylanbakircioglu
2026-01-26 15:25:16 +03:00
parent 25408a618e
commit eac00b3e39
2 changed files with 12 additions and 4 deletions
+6 -2
View File
@@ -1743,7 +1743,9 @@ check_config_updates() {
}
in_listen {
# Check if we hit another section (frontend, backend, listen, global, defaults)
if (/^(frontend|backend|listen|global|defaults)[[:space:]]/) {
# CRITICAL FIX: Match keywords followed by whitespace OR end of line
# This handles "defaults" without trailing whitespace
if (/^(frontend|backend|listen|global|defaults)([[:space:]]|$)/) {
# Print current listen block
gsub(/\n[[:space:]]*$/, "", listen_content)
print listen_content
@@ -2925,7 +2927,9 @@ CONFIG_RESPONSE_EOF
}
in_listen {
# Check if we hit another section (frontend, backend, listen, global, defaults)
if (/^(frontend|backend|listen|global|defaults)[[:space:]]/) {
# CRITICAL FIX: Match keywords followed by whitespace OR end of line
# This handles "defaults" without trailing whitespace
if (/^(frontend|backend|listen|global|defaults)([[:space:]]|$)/) {
# Print current listen block
gsub(/\n[[:space:]]*$/, "", listen_content)
print listen_content
+6 -2
View File
@@ -1689,7 +1689,9 @@ check_config_updates() {
}
in_listen {
# Check if we hit another section (frontend, backend, listen, global, defaults)
if (/^(frontend|backend|listen|global|defaults)[[:space:]]/) {
# CRITICAL FIX: Match keywords followed by whitespace OR end of line
# This handles "defaults" without trailing whitespace
if (/^(frontend|backend|listen|global|defaults)([[:space:]]|$)/) {
# Print current listen block
gsub(/\n[[:space:]]*$/, "", listen_content)
print listen_content
@@ -2873,7 +2875,9 @@ CONFIG_RESPONSE_EOF
}
in_listen {
# Check if we hit another section (frontend, backend, listen, global, defaults)
if (/^(frontend|backend|listen|global|defaults)[[:space:]]/) {
# CRITICAL FIX: Match keywords followed by whitespace OR end of line
# This handles "defaults" without trailing whitespace
if (/^(frontend|backend|listen|global|defaults)([[:space:]]|$)/) {
# Print current listen block
gsub(/\n[[:space:]]*$/, "", listen_content)
print listen_content