From 3c522a7aa235f63ae0439e5674e7406e20c90956 Mon Sep 17 00:00:00 2001 From: Lenard Hess Date: Thu, 4 Jan 2024 18:14:46 +0100 Subject: [PATCH] Config parsing: Allow trailing comments after a backslash in the config The cloudflare documentation example had lines with a comment after a backslash. This actually did not work in the parser until now. The lines in question: #protocol=cloudflare, \ #zone=domain.tld, \ #ttl=1, \ #login=your-login-email, \ # Only needed if you are using your global API key. If you are using an API token, set it to "token" (without double quotes). #password=APIKey \ # This is either your global API key, or an API token. If you are using an API token, it must have the permissions "Zone - DNS - Edit" and "Zone - Zone - Read". The Zone resources must be "Include - All zones". #domain.tld,my.domain.tld --- ddclient.in | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ddclient.in b/ddclient.in index dcefdba..834dcb8 100755 --- a/ddclient.in +++ b/ddclient.in @@ -1619,10 +1619,15 @@ sub _read_config { ## remove comments s/#.*//; - ## handle continuation lines + ## Handle continuation lines + # Any line ending in a backslash gets concatenated together with the following line + # Note: Trailing whitespace after the backslash is allowed. $_ = "$continuation$_"; - if (/\\$/) { - chop; + if (/\\\s*$/) { + # Remove the backslash and whitespace + s/\\\s*$//s; + + # Store the current line to be prepended to the next line $continuation = $_; next; }