Support Forums

Old 12-19-2007, 08:59 PM   #1
PHP Mechanic
 
 
Join Date: Nov 2007
Posts: 118
Rep Power: 9
cheesegrits has a spectacular aura about
Default xss_clean() problems

I'm seeing problems with this line in xss_clean():

Code:
$str = preg_replace('#(<[^>]+.*?)(onblur|onchange|onclick|onfocus|onload|onmouseover|onmouseup|onmousedown|onselect|onsubmit|onunload|onkeypress|onkeydown|onkeyup|onresize)[^>]*>#iU',"\\1>",$str);
With what should be valid input (no matches), the preg_replace blows $str away by returning NULL, rather than returning the string unchanged. I've been noodling around with it in a test script, and I think it may be tickling a bug in PHP 5.2. Once there are a certain number of potential matches (<foo), it just gives up and returns NULL. Seems to work OK on earlier versions of PHP.

Is anyone else seeing this? Symptom is that you create a formatted description (for, say a Seller Store) in TinyMCE, submit it, and it comes back blank.

-- hugh
cheesegrits is offline   Reply With Quote
Old 12-20-2007, 12:50 PM   #2
PHP Mechanic
 
 
Join Date: Nov 2007
Posts: 118
Rep Power: 9
cheesegrits has a spectacular aura about
Default

I worked round the problem thusly:

Around line 764 in functions.php:

Code:
                        // $$$ hugh - wrapped preg_match around the preg_replace, because the preg_replace
                        // return NULL on some perfectly valid inputs.  So only run the replace if there is
                        // actually a js action in the string.
                        $js_re = '#(<[^>]+.*?)(onblur|onchange|onclick|onfocus|onload|onmouseover|onmouseup|onmousedown|onselect|onsubmit|onunload|onkeypress|onkeydown|onkeyup|onresize)[^>]*>#iU';
                        if (preg_match($js_re,$str)) {
                                $str = preg_replace($js_re,"\\1>",$str);
                        }
-- hugh
cheesegrits is offline   Reply With Quote

Bookmarks

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
2 problems solved by change of Host. Grebogreen v3.1 Questions & Support 5 06-24-2008 10:59 AM
Image upload problems... Mikael v3.1 Questions & Support 13 02-22-2007 08:46 AM
Two problems xaphid v3.0 Questions & Support 1 02-08-2007 02:31 PM
Problems with updateOrder function flyingpylon v3.1 Questions & Support 3 11-06-2006 08:58 PM
If your having problems after an upgrade... From old forum calaf6 v3.0 Questions & Support 0 03-30-2006 04:44 PM


All times are GMT -4. The time now is 04:43 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0