sanitization

zend framework sanitizing data

回眸只為那壹抹淺笑 提交于 2019-12-06 03:23:46
I've seen different comments all over the place, some say that zend framework automatically sanitizes post/get data but others say it doesn't. What's the deal? I've seen that doing it in the predispatch with a foreach on getParams is the quickest way, but does anyone have any suggestions? Probably the deal is about Zend_Controller_Request vs the Zend_Db . Request data are often put into the DB. Request object does not escape anything. You may force it to do using filters, form filters or e.g. using the reflection technique described here: Actions, now with parameters! Zend_Db queries are

Data Sanitization in PHP [closed]

戏子无情 提交于 2019-12-06 00:32:27
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . Can someone recommend an up to date library for data Sanitization in PHP ? I am looking for a library that proposes a set of functions

What is the correct way to make web form input safe for a variety of contexts?

拟墨画扇 提交于 2019-12-05 22:01:49
问题 What do you all think is the correct (read: most flexible, loosely coupled, most robust, etc.) way to make user input from the web safe for use in various parts of a web application? Obviously we can just use the respective sanitization functions for each context (database, display on screen, save on disk, etc.), but is there some general "pattern" for handling unsafe data and making it safe? Is there an established way to enforce treating it as unsafe unless it is properly made safe? 回答1:

Javascript XSS Prevention

爷,独闯天下 提交于 2019-12-05 11:37:19
There is a Node.js project that sanitizes data and there is an OWASP library for JavaScript that handles sanitization to prevent XSS. I have been benchmarking these libraries, and they are pretty intensive and maybe an overkill, my application does not need any dynamic HTML (submitted by users, bbtags or what ever, not required at all) so why not do it like this: Disable " < " and " > " characters, don't replace them or anything, just disable them, if the user submits these, give them a warning that these are disabled (client- and server-side validation) & => & " => " ' => ' / => / Encode

Should I use ENT_QUOTES with htmlspecialchars or not

元气小坏坏 提交于 2019-12-05 09:04:45
I am using php 5.4.4 running as UTF-8, and im not sure if I am using htmlspecialchars right. My strings / vars look like this: $text = "<p><span class='clx'>By:</span> ".htmlspecialchars($foo)."</span></p>"; echo $text; Do I have need to use ENT_QUOTES or is that only necessary when I have to echo something inside eg: href="$foo" or id='$foo' ? Atm, om only using htmlspecialchars inside closed html tags and not attributes. Just concatenate the var inside the string within a <p> tag and a </p> tag Thanks You should generally use it when taking data from database and inserting it into html

Best way to escape strings for sql inserts?

假如想象 提交于 2019-12-05 08:32:20
What is the best way to escape strings for sql inserts, updates? I want to allow special characters including ' and ". Is the best way to search and replace each string before I use it in an insert statement? Thanks Duplicate of: Best way to defend against mysql injection and cross site scripting You should be using parameterized queries (so by extension, a DB interface library that supports parameterized queries) so that SQL injection can't happen. If you're talking about data values for your fields, then the best way is to use mysql_real_escape_string() . (Some people like mysqli ; can't say

Cleaning all inline events from HTML tags

旧巷老猫 提交于 2019-12-05 01:32:21
问题 For HTML input, I want to neutralize all HTML elements that have inline js (onclick="..", onmouseout=".." etc). I am thinking, isn't it enough to encode the following chars? =,(,) So onclick="location.href='ggg.com'" will become onclick%3D"location.href%3D'ggg.com'" What am I missing here? Edit: I do need to accept active HTML (I can't escape it all or entities is it). 回答1: There's no simple method to accept HTML, but not scripts. You have to parse HTML to DOM, remove all unwanted elements

How to intercept and pre-process QueryStrings in Asp.Net

邮差的信 提交于 2019-12-05 01:24:58
问题 We send out registration urls to clients via email. Some of the email clients are turning the url into url <url> I think it may be happening when users forward the email onto themselves at which point the email client re-formats the original email (maybe) E.g. https://my.app.com/login.aspx?param=var Becomes https://my.app.com/login.aspx?param=var%20%3Chttps://my.app.com/login.aspx?param=var%3E Which rightly produces System.Web.HttpRequestValidationException: A potentially dangerous Request

Is this bad practice use of the error suppression operator?

丶灬走出姿态 提交于 2019-12-04 16:57:26
I'm working on a database driven site which is using normal database methods rather than prepared statements. Because of this I have to sanitise POST and GET variables when passed to a form action PHP script. There is a sanitise method defined which attempts to sanitise the user input as best as possible but I am trying to cut down the code that tests for the POST and GET variable's existence and the code for defining variables with default values if they don't exist. This is what I came up with but its leaving a bad taste in mine and other dev's mouth as we all feel that the error suppression

Why so much HTML input sanitization necessary?

蓝咒 提交于 2019-12-04 15:45:41
I have implemented a search engine in C for my html website. My entire web is programmed in C. I understand that html input sanitization is necessary because an attacker can input these 2 html snippets into my search page to trick my search page into downloading and displaying foreign images/scripts (XSS): <img src="path-to-attack-site"/> <script>...xss-code-here...</script> Wouldn't these attacks be prevented simply by searching for '<' and '>' and stripping them from the search query ? Wouldn't that render both scripts useless since they would not be considered html ? I've seen html