[wp-trac] [WordPress Trac] #24813: wp_add_inline_style behaviour changes with SCRIPT_DEBUG

WordPress Trac noreply at wordpress.org
Sun Oct 13 20:12:25 UTC 2013


#24813: wp_add_inline_style behaviour changes with SCRIPT_DEBUG
------------------------------+-----------------------------
 Reporter:  stephenharris     |       Owner:  SergeyBiryukov
     Type:  defect (bug)      |      Status:  reopened
 Priority:  normal            |   Milestone:  3.7
Component:  General           |     Version:  3.3
 Severity:  normal            |  Resolution:
 Keywords:  has-patch commit  |
------------------------------+-----------------------------

Comment (by georgestephanis):

 [http://core.trac.wordpress.org/attachment/ticket/24813/24813.6.diff
 24813.6.diff] just added -- adds the `s` (PCRE_DOTALL) flag to the
 `preg_replace` so that it will work with multi-line CSS being passed in.
 Otherwise, this would fail:

 {{{
 $data = "<style type='text/css'>
 .class {
         property: value;
 }
 </style>";

 echo preg_replace( '#<style[^>]*>(.*)</style>#i', '$1', $data );
 }}}

 as the dot-wildcard doesn't natively include line breaks.

 Also added a `trim` around the `preg_replace` as if the developer is doing
 it multi-line, it would leave a trailing line break, that we can safely
 dispose of.

 I also tweaked the tests from the previous patch to more accurately
 reflect line breaks, and use actual `selector { property: value; }`
 syntax, as well as specifying the initial 'handle' stylesheet as
 `http://example.com` rather than just a protocol-less `example.com`

 I've not tested the tests, so if someone could, that'd be super -- but I
 think I've got it all correct.

 I also corrected the spelling of `surpress` to `suppress` (pedant that I
 am)

--
Ticket URL: <http://core.trac.wordpress.org/ticket/24813#comment:17>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list