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

Just question about htmlspecialchars and this #128

Open
Pok4 opened this issue Aug 14, 2023 · 1 comment
Open

Just question about htmlspecialchars and this #128

Pok4 opened this issue Aug 14, 2023 · 1 comment

Comments

@Pok4
Copy link

Pok4 commented Aug 14, 2023

If I use this library on GET and POST requests, does i need to use and htmlspecialchars or no?
Like htmspecialchars($this->antiXss($_GET['getid']))?
I mostly pass this requests to sql queries..
Thanks.

@voku
Copy link
Owner

voku commented Aug 14, 2023

In a perfect world you do not to escape / clean html tags if you interact with sql. You need to use prepare statements or some kind of sql escaping (e.g. mysqli_real_escape_string). And only if you display your data, you need to escape the html tags.

But... sometimes it's hard to escape every variable that is displayed (especially if you do not use a template engine like twig) and then it maybe makes sense to use htmlspecialchars + anti-xss = https://github.com/voku/value_objects/blob/main/src/voku/value_objects/ValueObjectAntiXss.php

PS: you can use anti-xss without htmlspecialchars if you want to display the string as html / users will see e.g. a headline and not <h1>

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

No branches or pull requests

2 participants