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

fix(util/gpage): code scanning alert no. 9: Potentially unsafe quoting #3992

Merged
merged 3 commits into from
Dec 1, 2024

Conversation

houseme
Copy link
Member

@houseme houseme commented Dec 1, 2024

Fixes https://github.com/gogf/gf/security/code-scanning/9

To fix the problem, we need to ensure that the title parameter is properly escaped before being embedded in the HTML attribute. The best way to fix this is to use a proper HTML escaping function that will convert special characters to their corresponding HTML entities. This will prevent any special characters in the title from breaking the HTML structure.

We will use the html.EscapeString function from the html package to escape the title parameter. This function converts special characters like <, >, &, and " to their corresponding HTML entities.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@houseme houseme marked this pull request as ready for review December 1, 2024 10:12
@gqcn gqcn changed the title Fix code scanning alert no. 9: Potentially unsafe quoting fix(util/gpage): code scanning alert no. 9: Potentially unsafe quoting Dec 1, 2024
@gqcn gqcn merged commit 5aa7504 into master Dec 1, 2024
20 checks passed
@gqcn gqcn deleted the alert-autofix-9 branch December 1, 2024 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants