From bcbb332cdfdaa3ed11ea498a2b13f507b9c67cb8 Mon Sep 17 00:00:00 2001 From: tharikaGitHub Date: Mon, 1 Jul 2024 15:12:15 +0530 Subject: [PATCH] Modify cleanFileName method --- .../api/publisher/v1/common/mappings/ExportUtils.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1.common/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/common/mappings/ExportUtils.java b/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1.common/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/common/mappings/ExportUtils.java index 147f7d238ee6..132be77c881c 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1.common/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/common/mappings/ExportUtils.java +++ b/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1.common/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/common/mappings/ExportUtils.java @@ -502,8 +502,12 @@ private static String cleanFolderName(String name) { * @return Folder name which the unwanted characters are replaced */ private static String cleanFileName(String name) { - // Replace everything but [a-zA-Z0-9.-] - return name.replaceAll("[^a-zA-Z0-9\\.\\-]", "_"); + String docName = name; + if (docName != null) { + // Replace everything but [a-zA-Z0-9.-] + docName = docName.replaceAll("[^a-zA-Z0-9\\.\\-]", "_"); + } + return docName; } /**