diff --git a/dist/hap-sign-tool.jar b/dist/hap-sign-tool.jar index 61d6f805a0ed2f7045bbb00d3ad28f990146f4ef..839b254a8eb97cf2284d69268ecbab6eed3f2dec 100644 Binary files a/dist/hap-sign-tool.jar and b/dist/hap-sign-tool.jar differ diff --git a/hapsigntool/hap_sign_tool_lib/src/main/java/com/ohos/hapsigntool/utils/ProfileUtils.java b/hapsigntool/hap_sign_tool_lib/src/main/java/com/ohos/hapsigntool/utils/ProfileUtils.java index ab6d7f320a7ea7cc198de2f11ef3a54b18ba73df..f3ebae9d12737ca3d726722108b66c9e296f227a 100644 --- a/hapsigntool/hap_sign_tool_lib/src/main/java/com/ohos/hapsigntool/utils/ProfileUtils.java +++ b/hapsigntool/hap_sign_tool_lib/src/main/java/com/ohos/hapsigntool/utils/ProfileUtils.java @@ -25,6 +25,12 @@ import java.nio.charset.StandardCharsets; * Utils to process provision profile */ public class ProfileUtils { + /** + * Regular expressions without comments + * + */ + public static final String REGEX_REMOVE_COMMENTS = "(//.*)|(/\\*[\\s\\S]*?\\*/)"; + private ProfileUtils() { } @@ -35,9 +41,21 @@ public class ProfileUtils { * @return file data */ public static byte[] getProvisionContent(File input) throws IOException { - byte[] bytes = FileUtils.readFile(input); + byte[] bytes = removeComments(FileUtils.readFile(input)); Provision provision = FileUtils.GSON.fromJson(new String(bytes, StandardCharsets.UTF_8), Provision.class); Provision.enforceValid(provision); return bytes; } + + /** + * remove profile comments + * + * @param bytes bytes + * @return byte[] + */ + private static byte[] removeComments(byte[] bytes) { + String file = new String(bytes, StandardCharsets.UTF_8); + String newFile = file.replaceAll(REGEX_REMOVE_COMMENTS, ""); + return newFile.getBytes(); + } } \ No newline at end of file