Skip to content

Commit

Permalink
Use lazy lookahead to find the env key name
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Nied <[email protected]>
  • Loading branch information
peternied committed Oct 25, 2022
1 parent a44c85a commit f876447
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
public final class SecurityUtils {

protected final static Logger log = LogManager.getLogger(SecurityUtils.class);
private static final String ENV_PATTERN_SUFFIX = "\\.([\\w=():\\-_]+)((\\:\\-)?[\\w=():\\-_]*)\\}";
private static final String ENV_PATTERN_SUFFIX = "\\.([\\w=():\\-_]+?)(\\:\\-[\\w=():\\-_]*)?\\}";
static final Pattern ENV_PATTERN = Pattern.compile("\\$\\{env" + ENV_PATTERN_SUFFIX);
static final Pattern ENVBC_PATTERN = Pattern.compile("\\$\\{envbc" + ENV_PATTERN_SUFFIX);
static final Pattern ENVBASE64_PATTERN = Pattern.compile("\\$\\{envbase64" + ENV_PATTERN_SUFFIX);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ public class SecurityUtilsTest {
"=ExitCode",
"=C:",
"ProgramFiles(x86)",
"INPUT_GRADLE-HOME-CACHE-CLEANUP"
"INPUT_GRADLE-HOME-CACHE-CLEANUP",
"MYENV",
"MYENV:",
"MYENV::"
);
private final Collection<String> namesFromThisRuntimeEnvironment = System.getenv().keySet();

Expand Down

0 comments on commit f876447

Please sign in to comment.