Fix reggex issue when configuring wifi

scope_role_map^2
osh 1 year ago
parent 63c0606fdf
commit 0427959f23

@ -95,6 +95,9 @@ public class MetadataServiceImpl implements MetadataService {
@PathParam("metaKey") String metaKey) { @PathParam("metaKey") String metaKey) {
Metadata metadata; Metadata metadata;
try { try {
if (metaKey.contains("-")) {
metaKey = metaKey.replace('-', '_');
}
metadata = DeviceMgtAPIUtils.getMetadataManagementService().retrieveMetadata(metaKey); metadata = DeviceMgtAPIUtils.getMetadataManagementService().retrieveMetadata(metaKey);
return Response.status(Response.Status.OK).entity(metadata).build(); return Response.status(Response.Status.OK).entity(metadata).build();
} catch (MetadataManagementException e) { } catch (MetadataManagementException e) {
@ -144,6 +147,9 @@ public class MetadataServiceImpl implements MetadataService {
public Response deleteMetadataEntry( public Response deleteMetadataEntry(
@PathParam("metaKey") String metaKey) { @PathParam("metaKey") String metaKey) {
try { try {
if (metaKey.contains("-")) {
metaKey = metaKey.replace('-', '_');
}
DeviceMgtAPIUtils.getMetadataManagementService().deleteMetadata(metaKey); DeviceMgtAPIUtils.getMetadataManagementService().deleteMetadata(metaKey);
return Response.status(Response.Status.OK).entity("Metadata entry is deleted successfully.").build(); return Response.status(Response.Status.OK).entity("Metadata entry is deleted successfully.").build();
} catch (MetadataKeyNotFoundException e) { } catch (MetadataKeyNotFoundException e) {

@ -805,6 +805,9 @@ public class RequestValidationUtil {
new ErrorResponse.ErrorResponseBuilder() new ErrorResponse.ErrorResponseBuilder()
.setCode(HttpStatus.SC_BAD_REQUEST).setMessage(msg).build()); .setCode(HttpStatus.SC_BAD_REQUEST).setMessage(msg).build());
} }
if (metadata.getMetaKey().contains("-")) {
metadata.setMetaKey(metadata.getMetaKey().replace('-', '_'));
}
String regex = "^[a-zA-Z0-9_.]*$"; String regex = "^[a-zA-Z0-9_.]*$";
if (!metadata.getMetaKey().matches(regex)) { if (!metadata.getMetaKey().matches(regex)) {
String msg = "Request parameter metaKey should only contain period, " + String msg = "Request parameter metaKey should only contain period, " +

Loading…
Cancel
Save