From 6d3833cbf1b534e5dff17cc14ce1c95274f46beb Mon Sep 17 00:00:00 2001 From: Mike Bierlee Date: Tue, 11 Oct 2022 21:35:36 +0300 Subject: [PATCH] Test with comment inside quotes --- source/mirage/keyvalue.d | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/mirage/keyvalue.d b/source/mirage/keyvalue.d index 6619906..ee256b8 100644 --- a/source/mirage/keyvalue.d +++ b/source/mirage/keyvalue.d @@ -86,8 +86,10 @@ class KeyValueConfigFactory( enforce!ConfigCreationException(parts.length == 2, "Missing value assignment (L" ~ index.to!string ~ "): " ~ processedLine); auto value = parts[1].strip; - if (normalizeQuotedValues && (value.startsWith('"') || value.startsWith('\'')) - && (value.endsWith('"') || value.endsWith('\''))) { + if (normalizeQuotedValues && + value.length > 1 && + (value.startsWith('"') || value.startsWith('\'')) && + (value.endsWith('"') || value.endsWith('\''))) { value = value[1 .. $ - 1]; } @@ -227,12 +229,14 @@ version (unittest) { monkey = 'ape' human = ape excessiveWhitespace = ' ' + breaksWithComments = ' # Don't do this ' "); assert(config.get("baboon") == "ape"); assert(config.get("monkey") == "ape"); assert(config.get("human") == "ape"); assert(config.get("excessiveWhitespace") == " "); + assert(config.get("breaksWithComments") == "'"); } }