Skip to content

Commit

Permalink
- Issue #467
Browse files Browse the repository at this point in the history
  • Loading branch information
rathnapandi committed Mar 12, 2024
1 parent 77e76cf commit ca94003
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -476,4 +476,8 @@ public static Map<String,String> removeEmptyValuesFromMap(Map<String, String> ma
.filter(e -> !e.getValue().isEmpty())
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
}

public static String replaceSpecialChars(String fileName){
return fileName.replaceAll("[\\\\/:*?\"<>|]", "");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -367,4 +367,10 @@ void handleAppExceptionGeneric() {
Assert.assertEquals(99, Utils.handleAppException(exception, LoggerFactory.getLogger("Utils"), new ErrorCodeMapper()));
}
}

@Test
void replaceSplChars() {
Assert.assertEquals("api-old(XX) API OLD", Utils.replaceSpecialChars("api-old/(XX) API ** OLD**"));
Assert.assertEquals("api-old(XX) API OLD", Utils.replaceSpecialChars("api-old/(XX) API ** OLD**:"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.axway.apim.lib.EnvironmentProperties;
import com.axway.apim.lib.error.AppException;
import com.axway.apim.lib.error.ErrorCode;
import com.axway.apim.lib.utils.Utils;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
Expand Down Expand Up @@ -59,7 +60,7 @@ public void saveAPILocally(ExportAPI exportAPI, APIResultHandler apiResultHandle
String targetFile = null;
String configFile;
try {
targetFile = localFolder.getCanonicalPath() + "/" + exportAPI.getName() + apiDef.getAPIDefinitionType().getFileExtension();
targetFile = localFolder.getCanonicalPath() + "/" + Utils.replaceSpecialChars(exportAPI.getName()) + apiDef.getAPIDefinitionType().getFileExtension();
if (!(apiDef instanceof WSDLSpecification && EnvironmentProperties.RETAIN_BACKEND_URL) && (!EnvironmentProperties.PRINT_CONFIG_CONSOLE)) {
writeBytesToFile(apiDef.getApiSpecificationContent(), targetFile);
exportAPI.getAPIDefinition().setApiSpecificationFile(exportAPI.getName() + apiDef.getAPIDefinitionType().getFileExtension());
Expand Down

0 comments on commit ca94003

Please sign in to comment.