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

Filter Input, Escape Output #13

Open
auroraeosrose opened this issue Apr 18, 2014 · 5 comments
Open

Filter Input, Escape Output #13

auroraeosrose opened this issue Apr 18, 2014 · 5 comments

Comments

@auroraeosrose
Copy link

Security is a mindset, not an after the fact addition

The db stuff does a good job of mentioning using bound params to deal with sql injection but there is nothing about the other end of security - FIEO

From the first moment POST and GET are mentioned and used the idea of filtering input (validating you got what you expected) and escaping output (a wrapper with htmlspecialchars would suffice for beginners) should be introduced

Just the basics are needed, nothing fancy - an output escaper function/method to use when echoing stuff out and the use of filter_var to make sure data is right from a POST is plenty good for a beginner level, but introducing the idea of "the user is a jerk and will try to break stuff" is good for beginning dev minds ;)

@elstamey
Copy link

I am looking at this issue, and I assume this is here:
Adding Topics
Editing Topics

to filter the inputs, I would use filter_var() and strip_tags for escaping the output.

Does that seem on par with what you were looking for, @auroraeosrose ?

@auroraeosrose
Copy link
Author

yes to filter_var for validating the input (filter is such an overloaded term) - NO to strip_tags - you want htmlentiries/htmlspecialchars for escaping output - we don't want to try to sanitize, just escape :)

@elstamey
Copy link

thank you so much!

@auroraeosrose
Copy link
Author

No problem, Ask if you have more questions!

@halfer
Copy link

halfer commented Oct 24, 2014

Adding a +1 for this. I was going to raise it myself with my other reports, so thanks OP for raising it.

I've had it recommended to me that htmlspecialchars() should specify a character set explicitly, and the manual suggests the same.

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

3 participants