Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When html An error occurred when using input in SpecialCharsMapOrStruct #3173

Closed
1cccccc opened this issue Nov 24, 2023 · 1 comment · Fixed by #3841
Closed

When html An error occurred when using input in SpecialCharsMapOrStruct #3173

1cccccc opened this issue Nov 24, 2023 · 1 comment · Fixed by #3841
Assignees
Labels
done This issue is done, which may be release in next version. enhancement

Comments

@1cccccc
Copy link

1cccccc commented Nov 24, 2023

model

type AdminAddInput struct {
	Name     string  `json:"name"`     //用户名
	Password string  `json:"password"` //密码
	RoleIds  *string `json:"roleIds"`  //角色列表
	IsAdmin  uint8   `json:"isAdmin"`  //是否是管理员
}

logic

func (a *sAdmin) Add(ctx context.Context, input model.AdminAddInput) error {
	if err := ghtml.SpecialCharsMapOrStruct(input); err != nil {
		return gerror.New(exceptions.XssException)
	}
	//业务代码
        return nil
}

接口请求参数如下
The interface request parameters are as follows
image

报错信息如下
The error message is as follows
image

换成地址传值却正常调用
Change to address and pass value but call normally
image

我的另一个接口不使用地址传值却也正常运行
My other interface doesn't use address transfer, but it still runs normally
image
image

@gqcn gqcn self-assigned this Oct 7, 2024
@gqcn
Copy link
Member

gqcn commented Oct 7, 2024

@1cccccc Hello, the input parameter of function ghtml.SpecialCharsMapOrStruct should be type of pointer. I'll improve the validation of the function.

@gqcn gqcn added the done This issue is done, which may be release in next version. label Oct 7, 2024
@gqcn gqcn closed this as completed in #3841 Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
done This issue is done, which may be release in next version. enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants