Jump to content

Odd Input Sanitation Problem


jjacquay712

Recommended Posts

I have a function that I use to sanitize all post and get user input. The problem is it randomly throws in the characters "rn" to the data. Here is what my code looks like:

 

<?php
function sanitize($input) {
if ( is_array($input) ) {
	foreach ( $input as $title=>$data ) {
		$input[$title] = stripslashes(mysql_real_escape_string($data));
	}	
	return $input;
} else {
	return stripslashes(mysql_real_escape_string($input));	
}
}

$_POST = sanitize($_POST);
$_GET = sanitize($_GET);
?>

 

When I comment out the lines

 

$_POST = sanitize($_POST); 
$_GET = sanitize($_GET);

 

It works normally. I am using tinymce as a JavaScript text editor (if that might make a difference). Any ideas about what the problem might be?

 

 

                                Thanks, John

Link to comment
https://forums.phpfreaks.com/topic/162157-odd-input-sanitation-problem/
Share on other sites

What is some sample data that get the error?  It may have to be with the input itself.  "rn" are coming from formatting issues.

 

"\n" means a new line.  Since you are stripping slashes it will yield simply a "n"

 

"\r" I believe has something to do with "tab" (or spaces??) and again stripping the slash out will yield just the single letter "r"

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.