From b009b80e47006435da7f995700908876d13d90a6 Mon Sep 17 00:00:00 2001 From: Daniel Kec Date: Mon, 13 Dec 2021 13:22:40 +0100 Subject: [PATCH] Don't escape config values Signed-off-by: Daniel Kec --- .../test/java/io/helidon/config/mp/MpConfigSourcesTest.java | 6 ++++-- .../src/main/java/io/helidon/config/ConfigHelper.java | 4 ++-- .../test/java/io/helidon/config/KeyTokenResolvingTest.java | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/config/config-mp/src/test/java/io/helidon/config/mp/MpConfigSourcesTest.java b/config/config-mp/src/test/java/io/helidon/config/mp/MpConfigSourcesTest.java index d16d882e84f..9483a2cbe66 100644 --- a/config/config-mp/src/test/java/io/helidon/config/mp/MpConfigSourcesTest.java +++ b/config/config-mp/src/test/java/io/helidon/config/mp/MpConfigSourcesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Oracle and/or its affiliates. + * Copyright (c) 2020, 2021 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,12 +46,14 @@ public class MpConfigSourcesTest { void testHelidonMap() { Map values = Map.of( "key.first", "first", - "key.second", "second" + "key.second", "second", + "key.third", "<>{}().,:;/|\\~`?!@#$%^&*-=+*" ); org.eclipse.microprofile.config.spi.ConfigSource mpSource = MpConfigSources.create(ConfigSources.create(values).build()); assertThat(mpSource.getValue("key.first"), is("first")); assertThat(mpSource.getValue("key.second"), is("second")); + assertThat(mpSource.getValue("key.third"), is("<>{}().,:;/|\\~`?!@#$%^&*-=+*")); } @Test void testHelidonParsable() { diff --git a/config/config/src/main/java/io/helidon/config/ConfigHelper.java b/config/config/src/main/java/io/helidon/config/ConfigHelper.java index 60b8f1a9a27..27ca5619998 100644 --- a/config/config/src/main/java/io/helidon/config/ConfigHelper.java +++ b/config/config/src/main/java/io/helidon/config/ConfigHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020 Oracle and/or its affiliates. + * Copyright (c) 2017, 2021 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +43,7 @@ public static Map flattenNodes(ConfigNode.ObjectNode objectNode) .filter(e -> e.getValue() instanceof ValueNodeImpl) .collect(Collectors.toMap( e -> e.getKey().toString(), - e -> Config.Key.escapeName(((ValueNodeImpl) e.getValue()).get()) + e -> ((ValueNodeImpl) e.getValue()).get() )); } diff --git a/config/config/src/test/java/io/helidon/config/KeyTokenResolvingTest.java b/config/config/src/test/java/io/helidon/config/KeyTokenResolvingTest.java index f7b13846169..8747dd2dbfc 100644 --- a/config/config/src/test/java/io/helidon/config/KeyTokenResolvingTest.java +++ b/config/config/src/test/java/io/helidon/config/KeyTokenResolvingTest.java @@ -231,7 +231,7 @@ public void testResolveTokenWithDottedValue() { Config config = Config.builder() .sources(ConfigSources.create(ConfigNode.ObjectNode.builder() - .addValue("domain", "oracle.com") + .addValue("domain", Config.Key.escapeName("oracle.com")) .addValue("$domain.sso", "on") .addValue(Config.Key.escapeName("seznam.cz") + ".sso", "off") .build()))