sanitize

Is <span style=…> safe for sanitize?

不问归期 提交于 2019-12-03 16:16:17
I am using a rich text editor (CKEditor) and I have the opportunity to let users create profiles that are displayed to other users. Many of the attributes CKEditor can control are being lost when I display them as: <%= sanitize(profile.body) %> My question is: is it safe to allow the attribute 'style' to be parsed? This would allow things like text color, size, background color, centering, indenting, etc. to be displayed. I just want to be sure it won't allow a hacker access to something I don't know about! is it safe to allow the attribute 'style' to be parsed? No. background-image: url

AngularJS create html/link/anchor from text (escape/unescape html in view)

倾然丶 夕夏残阳落幕 提交于 2019-12-03 12:34:33
问题 I have a controller that has an assigned value: $scope.post = 'please visit http://stackoverflow.com quickly'; I have some text in my html: <p>{{post}}</p> I would like to make a clickable link of the url (surround it with anchor tags). I tried to change my html to: <p ng-bind-html="post | createAnchors"></p> Here is a simplified example of the problem: http://jsfiddle.net/T3fFt/4/ The question is, how can I escape the whole post text, except for the link, which will be surrounded by anchor

How to sanitize sql fragment in Rails

╄→гoц情女王★ 提交于 2019-12-03 08:10:47
问题 I have to sanitize a part of sql query. I can do something like this: class << ActiveRecord::Base public :sanitize_sql end str = ActiveRecord::Base.sanitize_sql(["AND column1 = ?", "two's"], '') But it is not safe because I expose protected method. What is a better way to do it? 回答1: You can just use: ActiveRecord::Base::sanitize(string) 回答2: ActiveRecord::Base.connection.quote does the trick in Rails 3.x 回答3: This question does not specify that the answer has to come from ActiveRecord nor

AngularJS create html/link/anchor from text (escape/unescape html in view)

大城市里の小女人 提交于 2019-12-03 02:58:13
I have a controller that has an assigned value: $scope.post = 'please visit http://stackoverflow.com quickly'; I have some text in my html: <p>{{post}}</p> I would like to make a clickable link of the url (surround it with anchor tags). I tried to change my html to: <p ng-bind-html="post | createAnchors"></p> Here is a simplified example of the problem: http://jsfiddle.net/T3fFt/4/ The question is, how can I escape the whole post text, except for the link, which will be surrounded by anchor tags? ? I think you can use Angular's linky filter for this: https://docs.angularjs.org/api/ngSanitize

How to sanitize sql fragment in Rails

好久不见. 提交于 2019-12-02 21:47:30
I have to sanitize a part of sql query. I can do something like this: class << ActiveRecord::Base public :sanitize_sql end str = ActiveRecord::Base.sanitize_sql(["AND column1 = ?", "two's"], '') But it is not safe because I expose protected method. What is a better way to do it? HashDog Team You can just use: ActiveRecord::Base::sanitize(string) dimus ActiveRecord::Base.connection.quote does the trick in Rails 3.x Bryan Dimas This question does not specify that the answer has to come from ActiveRecord nor does it specify for which version of Rails it should be. For that reason (and because it

When to filter/sanitize data: before database insertion or before display?

爷,独闯天下 提交于 2019-12-02 20:30:22
As I prepare to tackle the issue of input data filtering and sanitization, I'm curious whether there's a best (or most used) practice? Is it better to filter/sanitize the data (of HTML, JavaScript, etc.) before inserting the data into the database, or should it be done when the data is being prepared for display in HTML? A few notes: I'm doing this in PHP, but I suspect the answer to this is language agnostic. But if you have any recommendations specific to PHP, please share! This is not an issue of escaping the data for database insertion. I already have PDO handling that quite well. Thanks!

Is it recommended to have a santizing function that combines two or more built in sanitizing functions in php?

本小妞迷上赌 提交于 2019-12-02 20:06:24
问题 Is it okay to employ a function that sanitizes the incoming inputs due to a form submission or any other request. It is time saving but the question of effectivenss and efficiency still haunts me. For instance, function clearSpecialChars($str) { $str=htmlentities($str); $str=strip_tags($str); $str=mysql_real_escape_string($str); return $str; } so that when I get a form submission I do: $username=clearSpecialChars($_REQUEST['username']); $email=clearSpecialChars($_REQUEST['email']);

Is it recommended to have a santizing function that combines two or more built in sanitizing functions in php?

情到浓时终转凉″ 提交于 2019-12-02 12:38:20
Is it okay to employ a function that sanitizes the incoming inputs due to a form submission or any other request. It is time saving but the question of effectivenss and efficiency still haunts me. For instance, function clearSpecialChars($str) { $str=htmlentities($str); $str=strip_tags($str); $str=mysql_real_escape_string($str); return $str; } so that when I get a form submission I do: $username=clearSpecialChars($_REQUEST['username']); $email=clearSpecialChars($_REQUEST['email']); Fundamentally, I am not desiring any html inputs from the user. each function serves its own purpose, you shouldn

Ruby on Rails: How to sanitize a string for SQL when not using find?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-30 13:53:26
问题 I'm trying to sanitize a string that involves user input without having to resort to manually crafting my own possibly buggy regex if possible, however, if that is the only way I would also appreciate if anyone can point me in the right direction to a regex that is unlikely to be missing anything. There are a number of methods in Rails that can allow you to enter in native SQL commands, how do people escape user input for those? The question I'm asking is a broad one, but in my particular

Codeigniter - best practice to sanitize input

本小妞迷上赌 提交于 2019-11-30 07:15:07
问题 I would like to know what's the best practice to sanitize user input using Codeigniter. I understands that CI offers form_validation, such as set_rules. 'set_rules'=>'trim|xss_clean|alpha_numeric|htmlspecialchars' "Any native PHP function that accepts one parameter can be used as a rule, like htmlspecialchars, trim, MD5, etc." My question now is, is this enough to protect us from xss, sql injection attacks etc? what other rules are there that I can apply? in term of performance, is it costly