diff --git a/README.md b/README.md index 1620509..c99d6c8 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ dependencies { ## What's New +* **0.6.9** Fixed some null pointer issues if content on base64encode was null and some exceptions on array traversal * **0.6.8** Fixed ! (not) operator and added base64encode, base64decode, textdecodebase64, textencodebase64 * **0.6.7** Fixed operators called on variables without spaces * **0.6.6** Fixed nested strings inside an interpolation syntax as well as some add conditional checks diff --git a/build.gradle b/build.gradle index 881dceb..3eab30f 100644 --- a/build.gradle +++ b/build.gradle @@ -30,7 +30,7 @@ ext { group = 'com.bertramlabs.plugins' -version = '0.6.8' +version = '0.6.9' ext.isReleaseVersion = !version.endsWith("SNAPSHOT") sourceCompatibility = "1.8" diff --git a/src/main/java/com/bertramlabs/plugins/hcl4j/HCLBaseFunctions.java b/src/main/java/com/bertramlabs/plugins/hcl4j/HCLBaseFunctions.java index be83738..2554242 100644 --- a/src/main/java/com/bertramlabs/plugins/hcl4j/HCLBaseFunctions.java +++ b/src/main/java/com/bertramlabs/plugins/hcl4j/HCLBaseFunctions.java @@ -402,7 +402,9 @@ static void registerCastingFunctions(HCLParser parser) { parser.registerFunction("base64encode", (arguments) -> { if(arguments.size() > 0) { String content = (String)(arguments.get(0)); - return Base64.getEncoder().encodeToString(content.getBytes(StandardCharsets.UTF_8)); + if(content != null) { + return Base64.getEncoder().encodeToString(content.getBytes(StandardCharsets.UTF_8)); + } } return null; }); @@ -410,8 +412,11 @@ static void registerCastingFunctions(HCLParser parser) { parser.registerFunction("base64decode", (arguments) -> { if(arguments.size() > 0) { String content = (String)(arguments.get(0)); - byte[] decodedBytes = Base64.getDecoder().decode(content); - return new String(decodedBytes,StandardCharsets.UTF_8); + if(content != null) { + byte[] decodedBytes = Base64.getDecoder().decode(content); + return new String(decodedBytes,StandardCharsets.UTF_8); + } + } return null; }); @@ -421,7 +426,9 @@ static void registerCastingFunctions(HCLParser parser) { if(arguments.size() > 1) { String content = (String)(arguments.get(0)); String encoding = (String)(arguments.get(1)); - return Base64.getEncoder().encodeToString(content.getBytes(Charset.forName(encoding))); + if(content != null) { + return Base64.getEncoder().encodeToString(content.getBytes(Charset.forName(encoding))); + } } return null; }); @@ -429,10 +436,13 @@ static void registerCastingFunctions(HCLParser parser) { parser.registerFunction("textdecodebase64", (arguments) -> { if(arguments.size() > 1) { String content = (String)(arguments.get(0)); - String encoding = (String)(arguments.get(1)); + if(content != null) { + String encoding = (String)(arguments.get(1)); - byte[] decodedBytes = Base64.getDecoder().decode(content); - return new String(decodedBytes,Charset.forName(encoding)); + byte[] decodedBytes = Base64.getDecoder().decode(content); + return new String(decodedBytes,Charset.forName(encoding)); + } + } return null; });