3v4l.org

run code in 200+ PHP versions simultaneously
<?php function wp_kses_split( $string, $allowed_html, $allowed_protocols ) { return preg_replace_callback( '%(<!--.*?(-->|$))|(<[^>]*(>|$)|>)%', function( $match ) use ($allowed_html, $allowed_protocols) { return wp_kses_split2( $match[0], $allowed_html, $allowed_protocols ); }, $string ); } function wp_kses_split2($string, $allowed_html, $allowed_protocols) { $string = str_replace( '\\"', '"', $string ); if (!preg_match('%^<\s*(/\s*)?([a-zA-Z0-9]+)([^>]*)>?$%', $string, $matches)) { return ''; } $slash = trim($matches[1]); $elem = $matches[2]; $attrlist = $matches[3]; if ($slash != '') return "</$elem>"; return wp_kses_attr( $elem, $attrlist, $allowed_html, $allowed_protocols ); } function wp_kses_attr($element, $attr, $allowed_html, $allowed_protocols) { $attrarr = array( array( 'name' => 'style', 'value' => '', 'whole' => "name=''", 'vless' => 'style' ) ); // Go through $attrarr, and save the allowed attributes for this element // in $attr2 $attr2 = ''; foreach ( $attrarr as $arreach ) { if ( wp_kses_attr_check( $arreach['name'], $arreach['value'], $arreach['whole'], $arreach['vless'], $element, $allowed_html ) ) { $attr2 .= ' '.$arreach['whole']; } } return "<$element$attr2>"; } function wp_kses_attr_check( &$name, &$value, &$whole, $vless, $element, $allowed_html ) { $allowed_attr = $allowed_html[strtolower( $element )]; $name_low = strtolower( $name ); if ( ! isset( $allowed_attr[$name_low] ) || '' == $allowed_attr[$name_low] ) { $name = $value = $whole = ''; return false; } if ( 'style' == $name_low ) { $new_value = safecss_filter_attr( $value ); if ( empty( $new_value ) ) { $name = $value = $whole = ''; return false; } $whole = str_replace( $value, $new_value, $whole ); $value = $new_value; } return true; } function safecss_filter_attr( $css, $element = 'div' ) { $css = $element . ' {' . $css . '}'; $css = wp_kses_split( $css, array(), array() ); $old = @setlocale(LC_ALL, 0); @setlocale(LC_ALL, 'C'); preg_match( "/[^\s\r\n\t\f]/", $css{0} ); @setlocale(LC_ALL, $old); return ''; } var_dump(PCRE_VERSION); $content = '<p style="">hola</p><p style="">hola</p>'; var_dump( wp_kses_split( addslashes( $content ), array('p'=>array('style' => array())), array() ) );
based on SM0Il
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4IVgb
function name:  (null)
number of ops:  16
compiled vars:  !0 = $content
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  62     0  E >   INIT_FCALL                                               'var_dump'
         1        SEND_VAL                                                 '10.33+2019-04-16'
         2        DO_ICALL                                                 
  63     3        QM_ASSIGN                                                !0
  64     4        INIT_FCALL                                               'var_dump'
         5        INIT_FCALL                                               'wp_kses_split'
         6        INIT_FCALL                                               'addslashes'
         7        SEND_VAR                                                 !0
         8        DO_ICALL                                         $3      
         9        SEND_VAR                                                 $3
        10        SEND_VAL                                                 <array>
        11        SEND_VAL                                                 <array>
        12        DO_FCALL                                      0  $4      
        13        SEND_VAR                                                 $4
        14        DO_ICALL                                                 
        15      > RETURN                                                   1

Function wp_kses_split:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4IVgb
function name:  wp_kses_split
number of ops:  13
compiled vars:  !0 = $string, !1 = $allowed_html, !2 = $allowed_protocols
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   RECV                                             !0      
         1        RECV                                             !1      
         2        RECV                                             !2      
   4     3        INIT_FCALL                                               'preg_replace_callback'
         4        SEND_VAL                                                 '%25%28%3C%21--.%2A%3F%28--%3E%7C%24%29%29%7C%28%3C%5B%5E%3E%5D%2A%28%3E%7C%24%29%7C%3E%29%25'
         5        RAISE_ABSTRACT_ERROR                             ~3      '%00%7Bclosure%7D%2Fin%2F4IVgb0x7f8914057b1a'
         6        BIND_LEXICAL                                             ~3, !1
         7        BIND_LEXICAL                                             ~3, !2
   6     8        SEND_VAL                                                 ~3
         9        SEND_VAR                                                 !0
        10        DO_ICALL                                         $4      
        11      > RETURN                                                   $4
   7    12*     > RETURN                                                   null

End of function wp_kses_split

Function %00%7Bclosure%7D%2Fin%2F4IVgb0x7f8914057b1a:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4IVgb
function name:  {closure}
number of ops:  12
compiled vars:  !0 = $match, !1 = $allowed_html, !2 = $allowed_protocols
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   4     0  E >   RECV                                             !0      
         1        BIND_STATIC                                              !1
         2        BIND_STATIC                                              !2
   5     3        INIT_FCALL_BY_NAME                                       'wp_kses_split2'
         4        CHECK_FUNC_ARG                                           
         5        FETCH_DIM_FUNC_ARG                               $3      !0, 0
         6        SEND_FUNC_ARG                                            $3
         7        SEND_VAR_EX                                              !1
         8        SEND_VAR_EX                                              !2
         9        DO_FCALL                                      0  $4      
        10      > RETURN                                                   $4
   6    11*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F4IVgb0x7f8914057b1a

Function wp_kses_split2:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 17
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 32
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4IVgb
function name:  wp_kses_split2
number of ops:  40
compiled vars:  !0 = $string, !1 = $allowed_html, !2 = $allowed_protocols, !3 = $matches, !4 = $slash, !5 = $elem, !6 = $attrlist
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   9     0  E >   RECV                                             !0      
         1        RECV                                             !1      
         2        RECV                                             !2      
  10     3        INIT_FCALL                                               'str_replace'
         4        SEND_VAL                                                 '%5C%22'
         5        SEND_VAL                                                 '%22'
         6        SEND_VAR                                                 !0
         7        DO_ICALL                                         $7      
         8        QM_ASSIGN                                                !0
  11     9        INIT_FCALL                                               'preg_match'
        10        SEND_VAL                                                 '%25%5E%3C%5Cs%2A%28%2F%5Cs%2A%29%3F%28%5Ba-zA-Z0-9%5D%2B%29%28%5B%5E%3E%5D%2A%29%3E%3F%24%25'
        11        SEND_VAR                                                 !0
        12        SEND_REF                                                 !3
        13        DO_ICALL                                         $9      
        14        BOOL_XOR                                         ~10     $9
        15      > JMPZ                                                     ~10, ->17
  12    16    > > RETURN                                                   ''
  14    17    >   INIT_FCALL                                               'trim'
        18        FETCH_DIM_R                                      ~11     !3, 1
        19        SEND_VAL                                                 ~11
        20        DO_ICALL                                         $12     
        21        QM_ASSIGN                                                !4
  15    22        FETCH_DIM_R                                      ~14     !3, 2
        23        QM_ASSIGN                                                !5
  16    24        FETCH_DIM_R                                      ~16     !3, 3
        25        QM_ASSIGN                                                !6
  18    26        IS_SMALLER                                       ~18     !4, ''
        27      > JMPZ                                                     ~18, ->32
  19    28    >   ROPE_INIT                                     3  ~20     '%3C%2F'
        29        ROPE_ADD                                      1  ~20     ~20, !5
        30        ROPE_END                                      2  ~19     ~20, '%3E'
        31      > RETURN                                                   ~19
  20    32    >   INIT_FCALL_BY_NAME                                       'wp_kses_attr'
        33        SEND_VAR_EX                                              !5
        34        SEND_VAR_EX                                              !6
        35        SEND_VAR_EX                                              !1
        36        SEND_VAR_EX                                              !2
        37        DO_FCALL                                      0  $22     
        38      > RETURN                                                   $22
  21    39*     > RETURN                                                   null

End of function wp_kses_split2

Function wp_kses_attr:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 29
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 29
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 28
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 28
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/4IVgb
function name:  wp_kses_attr
number of ops:  36
compiled vars:  !0 = $element, !1 = $attr, !2 = $allowed_html, !3 = $allowed_protocols, !4 = $attrarr, !5 = $attr2, !6 = $arreach
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  22     0  E >   RECV                                             !0      
         1        RECV                                             !1      
         2        RECV                                             !2      
         3        RECV                                             !3      
  23     4        QM_ASSIGN                                                !4
  26     5        QM_ASSIGN                                                !5
  27     6      > FE_RESET_R                                       $9      !4, ->29
         7    > > FE_FETCH_R                                               $9, !6, ->29
  28     8    >   INIT_FCALL_BY_NAME                                       'wp_kses_attr_check'
         9        CHECK_FUNC_ARG                                           
        10        FETCH_DIM_FUNC_ARG                               $10     !6, 'name'
        11        SEND_FUNC_ARG                                            $10
        12        CHECK_FUNC_ARG                                           
        13        FETCH_DIM_FUNC_ARG                               $11     !6, 'value'
        14        SEND_FUNC_ARG                                            $11
        15        CHECK_FUNC_ARG                                           
        16        FETCH_DIM_FUNC_ARG                               $12     !6, 'whole'
        17        SEND_FUNC_ARG                                            $12
        18        CHECK_FUNC_ARG                                           
        19        FETCH_DIM_FUNC_ARG                               $13     !6, 'vless'
        20        SEND_FUNC_ARG                                            $13
        21        SEND_VAR_EX                                              !0
        22        SEND_VAR_EX                                              !2
        23        DO_FCALL                                      0  $14     
        24      > JMPZ                                                     $14, ->28
  29    25    >   FETCH_DIM_R                                      ~15     !6, 'whole'
        26        CONCAT                                           ~16     '+', ~15
        27        ASSIGN_DIV                                    8          !5, ~16
  27    28    > > JMP                                                      ->7
        29    >   FE_FREE                                                  $9
  32    30        ROPE_INIT                                     4  ~19     '%3C'
        31        ROPE_ADD                                      1  ~19     ~19, !0
        32        ROPE_ADD                                      2  ~19     ~19, !5
        33        ROPE_END                                      3  ~18     ~19, '%3E'
        34      > RETURN                                                   ~18
  33    35*     > RETURN                                                   null

End of function wp_kses_attr

Function wp_kses_attr_check:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 18, Position 2 = 21
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 26
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 45
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 38
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 45
Branch analysis from position: 21
filename:       /in/4IVgb
function name:  wp_kses_attr_check
number of ops:  47
compiled vars:  !0 = $name, !1 = $value, !2 = $whole, !3 = $vless, !4 = $element, !5 = $allowed_html, !6 = $allowed_attr, !7 = $name_low, !8 = $new_value
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  34     0  E >   RECV                                             !0      
         1        RECV                                             !1      
         2        RECV                                             !2      
         3        RECV                                             !3      
         4        RECV                                             !4      
         5        RECV                                             !5      
  35     6        INIT_FCALL                                               'strtolower'
         7        SEND_VAR                                                 !4
         8        DO_ICALL                                         $9      
         9        FETCH_DIM_R                                      ~10     !5, $9
        10        QM_ASSIGN                                                !6
  36    11        INIT_FCALL                                               'strtolower'
        12        SEND_VAR                                                 !0
        13        DO_ICALL                                         $12     
        14        QM_ASSIGN                                                !7
  37    15        ISSET_ISEMPTY_DIM_OBJ                         0  ~14     !6, !7
        16        BOOL_XOR                                         ~15     ~14
        17      > JMPNZ_EX                                         ~15     ~15, ->21
        18    >   FETCH_DIM_R                                      ~16     !6, !7
        19        IS_NOT_EQUAL                                     ~17     ~16, ''
        20        BOOL                                             ~15     ~17
        21    > > JMPZ                                                     ~15, ->26
  38    22    >   QM_ASSIGN                                        $18     !2
        23        QM_ASSIGN                                        $19     !1
        24        QM_ASSIGN                                                !0
  39    25      > RETURN                                                   <false>
  41    26    >   IS_NOT_EQUAL                                     ~21     !7, 'style'
        27      > JMPZ                                                     ~21, ->45
  42    28    >   INIT_FCALL_BY_NAME                                       'safecss_filter_attr'
        29        SEND_VAR_EX                                              !1
        30        DO_FCALL                                      0  $22     
        31        QM_ASSIGN                                                !8
  43    32        ADD_TRAIT                                        ~24     !8
        33      > JMPZ                                                     ~24, ->38
  44    34    >   QM_ASSIGN                                        $25     !2
        35        QM_ASSIGN                                        $26     !1
        36        QM_ASSIGN                                                !0
  45    37      > RETURN                                                   <false>
  47    38    >   INIT_FCALL                                               'str_replace'
        39        SEND_VAR                                                 !1
        40        SEND_VAR                                                 !8
        41        SEND_VAR                                                 !2
        42        DO_ICALL                                         $28     
        43        QM_ASSIGN                                                !2
  48    44        QM_ASSIGN                                                !1
  50    45    > > RETURN                                                   <true>
  51    46*     > RETURN                                                   null

End of function wp_kses_attr_check

Function safecss_filter_attr:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4IVgb
function name:  safecss_filter_attr
number of ops:  38
compiled vars:  !0 = $css, !1 = $element, !2 = $old
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  52     0  E >   RECV                                             !0      
         1        RECV_INIT                                        !1      'div'
  53     2        CONCAT                                           ~3      !1, '+%7B'
         3        CONCAT                                           ~4      ~3, !0
         4        CONCAT                                           ~5      ~4, '%7D'
         5        QM_ASSIGN                                                !0
  54     6        INIT_FCALL                                               'wp_kses_split'
         7        SEND_VAR                                                 !0
         8        SEND_VAL                                                 <array>
         9        SEND_VAL                                                 <array>
        10        DO_FCALL                                      0  $7      
        11        QM_ASSIGN                                                !0
  55    12        BEGIN_SILENCE                                    ~9      
        13        INIT_FCALL                                               'setlocale'
        14        SEND_VAL                                                 6
        15        SEND_VAL                                                 0
        16        DO_ICALL                                         $10     
        17        END_SILENCE                                              ~9
        18        QM_ASSIGN                                                !2
  56    19        BEGIN_SILENCE                                    ~12     
        20        INIT_FCALL                                               'setlocale'
        21        SEND_VAL                                                 6
        22        SEND_VAL                                                 'C'
        23        DO_ICALL                                                 
        24        END_SILENCE                                              ~12
  57    25        INIT_FCALL                                               'preg_match'
        26        SEND_VAL                                                 '%2F%5B%5E%5Cs%0D%0A%09%0C%5D%2F'
        27        FETCH_DIM_R                                      ~14     !0, 0
        28        SEND_VAL                                                 ~14
        29        DO_ICALL                                                 
  58    30        BEGIN_SILENCE                                    ~16     
        31        INIT_FCALL                                               'setlocale'
        32        SEND_VAL                                                 6
        33        SEND_VAR                                                 !2
        34        DO_ICALL                                                 
        35        END_SILENCE                                              ~16
  59    36      > RETURN                                                   ''
  60    37*     > RETURN                                                   null

End of function safecss_filter_attr

Generated using Vulcan Logic Dumper, using php 7.4.0