From 685e7891c0b8801aa9957b2af83d3f6dd79d2fce Mon Sep 17 00:00:00 2001 From: CaptainB Date: Tue, 30 Jan 2024 11:16:50 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=A4=84=E7=90=86request=20body=20strin?= =?UTF-8?q?g=E5=A4=9A=E4=BA=86=E5=BC=95=E5=8F=B7=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/metersphere/system/controller/LicenseController.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/LicenseController.java b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/LicenseController.java index 40bb06824d..5ac63291c0 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/LicenseController.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/LicenseController.java @@ -7,6 +7,7 @@ import io.metersphere.sdk.util.CommonBeanFactory; import io.metersphere.system.utils.SessionUtils; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import org.apache.commons.lang3.StringUtils; import org.apache.shiro.authz.annotation.Logical; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.web.bind.annotation.*; @@ -30,6 +31,8 @@ public class LicenseController { @RequiresPermissions(value= {PermissionConstants.SYSTEM_AUTH_READ, PermissionConstants.SYSTEM_AUTH_READ_UPDATE}, logical = Logical.OR) public LicenseDTO addLicense(@RequestBody String licenseCode) { LicenseService licenseService = CommonBeanFactory.getBean(LicenseService.class); + // 前端传入的JSON会被加上双引号,需要去掉 + licenseCode = StringUtils.strip(licenseCode, "\""); if (licenseService != null) { return licenseService.addLicense(licenseCode, SessionUtils.getUserId()); }