[wp-trac] [WordPress Trac] #17035: kses speed up
WordPress Trac
wp-trac at lists.automattic.com
Sun Apr 3 19:01:24 UTC 2011
#17035: kses speed up
-------------------------+-----------------------
Reporter: duck_ | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: 3.2
Component: Performance | Version:
Severity: normal | Keywords: has-patch
-------------------------+-----------------------
The attached patch optimises some parts of kses by removing a regular
expression and instances of error suppression. It gives the greatest
benefit when processing large, mark-up rich content -- up to 1s over 1k
runs.
The regex can be removed because it's aiming to grab the content between
opening an closing HTML comment tags, but doesn't care if it's closed. So
we can just check for the opening tag and then do the same str_replace to
remove the opening/closing tags as well as any encapsulated ones.
The other part to explain is:
{{{
if ( ! isset($allowed_html[strtolower($element)]) ||
count($allowed_html[strtolower($element)]) == 0 )
}}}
It does look strange to return the element if it's not set in
`$allowed_html`, but it is consistent with the current code. Other options
could be to assume that we have always had non-whitelisted tags removed
and not bother with the `isset` or move the `isset` to it's own check an
return empty string.
It performs the same in all my tests (which I still need to make public).
These are essentially checking everything from ha.ckers.org/xss.html as
well as some more generic tests, especially to do with bad protocols.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/17035>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list