Skip to content

Commit

Permalink
Merge pull request #585 from eclipse/win-env-var
Browse files Browse the repository at this point in the history
Processing of configurations raised issues in Windows
  • Loading branch information
serenaponta authored Apr 28, 2023
2 parents b74c7d7 + 56a7d3c commit 8565716
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
Expand Down Expand Up @@ -214,7 +215,7 @@ private void appendInitialConfigurations() {
}

// Add: Environment variables
final Map<String, String> env = System.getenv();
final Map<String, String> env = new ProcessBuilder().environment();
Configuration env_config = new MapConfiguration(env);
addConfiguration(env_config, ENV_CFG_LAYER);

Expand Down Expand Up @@ -298,14 +299,18 @@ private void addConfiguration(Configuration _cfg, String _source) {
*/
public void sanitize(Configuration _cfg) {
final Iterator<String> i = _cfg.getKeys();
List<String> keys_to_remove = new ArrayList<String>();
while (i.hasNext()) {
final String k = i.next();
final Matcher m = KEY_PATTERN.matcher(k);
if (!m.matches()) {
getLog().warn("Configuration key [" + k + "] removed due to illegal characters");
_cfg.clearProperty(k);
keys_to_remove.add(k);
}
}
for (String p : keys_to_remove) {
_cfg.clearProperty(p);
}
}

/**
Expand Down

0 comments on commit 8565716

Please sign in to comment.