commit cd855a52e4b61839ee5cf0092158bdd035a2612c
parent 3ddab3227044d1b39c3a4cd85a946cb408aca1a2
Author: Florian Dold <dold@taler.net>
Date: Tue, 21 Jul 2026 12:36:44 +0200
util: normalize tabs and carriage returns before parsing a config line
Splitting on "\n" leaves the "\r" of a CRLF file on every line, where it
stopped the comment pattern from matching: a comment became a parse error,
or, if it contained an "=", a live option assignment.
Diffstat:
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/packages/taler-util/src/talerconfig.ts b/packages/taler-util/src/talerconfig.ts
@@ -496,8 +496,15 @@ export class Configuration {
let currentSection: string | undefined = undefined;
const lines = s.split("\n");
- for (const line of lines) {
+ for (const rawLine of lines) {
lineNo++;
+ // Tabs and carriage returns count as whitespace and are rewritten
+ // before the line is classified, as GNUnet's configuration.c does.
+ // Splitting on "\n" leaves the "\r" of a CRLF file at the end of every
+ // line, where it stops the comment pattern from matching: a comment
+ // then falls through to the parse error, or, if it contains an "=", is
+ // taken for a live option assignment.
+ const line = rawLine.replace(/[\t\r]/g, " ");
if (reEmptyLine.test(line)) {
continue;
}