sanitize

Best way to Sanitize / Filter Comments from users?

I am currently using this process to Sanitize/Filter comment entered by users -> This one is used to strip slashes... and if (get_magic_quotes_gpc()) { function stripslashes_deep($value) { $value = is_array($value) ? array_map('stripslashes_deep', $value) : st...

Sanitize input XSS and HTML input in rails

I know I can use the ActionView helper strip_tags method in my views to sanitize output, but what is the best way to sanitize user input before I persist it to my db? Should I find a way to include the view helper in my controller and reuse the strip_tags method? I thought rails would have something available globally to do something l...

Ruby Sanitize Code ... why is & sanitized ...

I currently use the following code to sanitize a string before storing them: ERB::Util::h(string) My problem occurs when the string has been sanitized already like this: string = "Watching baseball & football" The sanitized string will look like: sanitized_string = "Watching baseball & football" Can I sanitize by just t...

Problem with Ruby Gem and Sanitize

Hi, I'm trying to install the Ruby gem sanitize. I've already installed nokogiri: >gem list nokogiri *** LOCAL GEMS *** nokogiri (1.4.0) but when I try and install sanitize I get the following error: >gem install rgrove-sanitize ERROR: Error installing rgrove-sanitize: rgrove-sanitize requires nokogiri (~> 1.3.3, runtime) ...

Anonymize pom.xml on release

I've got artefacts which are built and released using Maven. The artefact's original pom.xml contains the usual project information (artifactId, name, etc.) and the dependencies. That's fine. But the pom.xml also includes private information such as the SCM URLs, the names of the developers or a parent-artefact. Is there any way to tell...

filtering user input in php

hello guys, Am wondering if the combination of trim(), strip_tags() and addslashes() is enough to filter values of variables from $_GET and $_POST ...

Performance concerns on sanitizing all user input using PHP array_map

Hi, I'm running this function to sanitize all user input through out my site, but it worries me that it may be very performance intensive... // function for cleaning arrays, recursively for arrays held inside arrays function array_clean($array) { // if its an array, walk each element recursively if(is_array($ar...

sanitizing pre-filled user-supplied form input

I have a form which accepts text input. I would like it to be able to accept characters such as & and ; and > and <, which are useful characters for the data being supplied by the user. I want the user to, for example, be able to say The ampersand (&) is encoded as & (and I see from the preview that I can't even do that here - it shou...

PHP - is this function pair suitable sanitization?

This was taken from O'Reilly's Learn PHP, MySQL, and Javascript: function sanitizeString($var) { $var = stripslashes($var); $var = htmlentities($var); $var = strip_tags($var); return $var; } function sanitizeMySQL($var) { $var = sanitizeString($var); $var = mysql_real_escape_string($var); return $var; } Is...

Is it safe to use user input for Python's regular expressions?

I would like to let my users use regular expressions for some features. I'm curious what the implications are of passing user input to re.compile(). I assume there is no way for a user to give me a string that could let them execute arbitrary code. The dangers I have thought of are: The user could pass input that raises an exception...

Using Wordpress, can some one tell me the best way of sanitizing input?

Hi, I'm developing an application using Wordpress as a CMS. I have a form with a lot of input fields which needs to be sanitized before stored in the database. I want to prevent SQL injection, having javascript and PHP code injected and other harmful code. Currently I'm using my own methods to sanitize data, but I feel that it might b...

How do I allow rails to have javascript: in the data

I have a database of ad html, and some of them contain Javascript functions. Is there a way to have rails allow javascript: tags for a particular attribute on a particular model? To clarify further, I can bring the html up in an edit form, but when I try to submit, my browser (Firefox) says the connection is reset. IE gives me an error...

sanitize on controller

Is there anything like sanitize for controllers? thanks ...

PHP FILTER_SANITIZE_URL swedish domain name

I am experimenting with filter_input and filter_var and I am currently trying to sanitize URLs with FILTER_SANITIZE_URL. The test program gets input from a GET variable which consists of a URL, (ex. foo.com/bar.php?a=http://www.domain.se). It works fine as long as I don't use swedish domain names. Ex: (foo.com/bar.php?a=http://www.äta.se...

Replacing special chars from the output

searchVersion: function (dataString) { var index = dataString.indexOf(this.versionSearchString); if (index == - 1) return; return parseFloat(dataString.substring(index + this.versionSearchString.length + 1)); } ... returns browser version, in my case, its "3.6". Since I'm going to use this as a class name, I want to remove ...

Best way to sanitize content with PHP?

Which is the best way to "sanitize" content? An example... Example - Before sanitize: Morbi mollis ante vitae massa suscipit a tempus est pellentesque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nulla mattis iaculis consectetur. Morbi mollis ante vitae est pellentesque. Pellentesque ha...

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

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 t...

NameError: uninitialized constant Nokogiri::HTML::DocumentFragment

About three hours ago I started seeing the above error in my production server. It comes from a call to the sanitize gem: vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:276:in 'load_missing_constant' vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:468:in `const_m...

safely encode and pass a string from a html link to PHP program

What series of steps would be reqired to safely encode and pass a string from a html href using javascript to construct the link to a php program. in javascript set up URL // encodes a URI component. path = "mypgm.php?from=" + encodeURIComponent(myvar) ; in php: // get passed variables $myvar = isset($_GET['myvar']) ? ($_GET['myva...

Best Practices for Sanitizing SQL inputs Using JavaScript?

So, with HTML5 giving us local SQL databases on the client side, if you want to write a select or insert, you no longer have the ability to sanitize third party input by saying $buddski = mysql_real_escape_string($tuddski) because the PHP parser and MySQL bridge are far away. It's a whole new world of SQLite where you compose your querie...