Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
User input sanitization error
Old 08-10-2010, 12:06 PM User input sanitization error
Extreme Talker

Posts: 173
Trades: 0
I am asking the user to provide a directory where a file can be found, however, when I put the string through sanitization, it adds in additional "\", and displays them as part of the text string.

PHP Code:
strtolower(mysql_real_escape_string($_POST["url"])) 
Input:
Display:
dgkindy is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-10-2010, 01:17 PM Re: User input sanitization error
lynxus's Avatar
Awesomeo-Maximo

Posts: 1,618
Location: UK
Trades: 1
Its escaping the \ by the looks of things.

Maybe just to hack it, Use str_replace and replace any \\ with a \ after your sanitization.
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


lynxus is offline
Reply With Quote
View Public Profile Visit lynxus's homepage!
 
Old 08-10-2010, 03:46 PM Re: User input sanitization error
Extreme Talker

Posts: 149
Trades: 0
@lynxus is right,
\ must be escaped
__________________
Free
Please login or register to view this content. Registration is FREE

Visit our
Please login or register to view this content. Registration is FREE
and
Please login or register to view this content. Registration is FREE
mimamo is offline
Reply With Quote
View Public Profile
 
Old 08-10-2010, 03:54 PM Re: User input sanitization error
lynxus's Avatar
Awesomeo-Maximo

Posts: 1,618
Location: UK
Trades: 1
Then again, Have you tried inputting the output into mysql?

Its possible that it will enter it correctly as mysql will just ignore the first \ ?
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


lynxus is offline
Reply With Quote
View Public Profile Visit lynxus's homepage!
 
Old 08-11-2010, 04:13 AM Re: User input sanitization error
bajick's Avatar
Junior Talker

Posts: 3
Name: Jick
Trades: 0
That's because Magic Quotes in php is enabled. What you may do is to turn it off and make a temporary variable (let's say $tmp_str = $str) to hold your string. Make addslahes() to that variable ($tmp_str) and pass it on to your mysql query. If you want to send your string back to the browser, just echo your original variable ($str).
bajick is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to User input sanitization error
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 1.11548 seconds with 12 queries