| 920 | | $uris = array('xmlns', 'profile', 'href', 'src', 'cite', 'classid', 'codebase', 'data', 'usemap', 'longdesc', 'action'); |
| | 920 | $uris = array( 'xmlns', 'profile', 'href', 'src', 'srcset', 'sizes', 'cite', 'classid', 'codebase', 'data', 'usemap', 'longdesc', 'action' ); |
| 962 | | if (preg_match('%^"([^"]*)"(\s+|/?$)%', $attr, $match)) |
| 963 | | // "value" |
| 964 | | { |
| 965 | | $thisval = $match[1]; |
| 966 | | if ( in_array(strtolower($attrname), $uris) ) |
| 967 | | $thisval = wp_kses_bad_protocol($thisval, $allowed_protocols); |
| | 960 | $scenarios = array( |
| | 961 | array( '%^"([^"]*)"(\s+|/?$)%', "$attrname=\"$thisval\"", '/^"[^"]*"(\s+|$)/' ), // "value" |
| | 962 | array( "%^'([^']*)'(\s+|/?$)%", "$attrname='$thisval'", "/^'[^']*'(\s+|$)/" ), // 'value' |
| | 963 | array( "%^([^\s\"']+)(\s+|/?$)%", "$attrname=\"$thisval\"", "%^[^\s\"']+(\s+|$)%" ), // value |
| | 964 | ); |
| 969 | | if(false === array_key_exists($attrname, $attrarr)) { |
| 970 | | $attrarr[$attrname] = array ('name' => $attrname, 'value' => $thisval, 'whole' => "$attrname=\"$thisval\"", 'vless' => 'n'); |
| 971 | | } |
| 972 | | $working = 1; |
| 973 | | $mode = 0; |
| 974 | | $attr = preg_replace('/^"[^"]*"(\s+|$)/', '', $attr); |
| 975 | | break; |
| 976 | | } |
| | 966 | foreach ( $scenarios as $key => $scenario ) { |
| | 967 | if ( preg_match( $scenario[0], $attr, $match ) ) { |
| | 968 | $thisval = $match[1]; |
| | 969 | if ( in_array( strtolower( $attrname ), $uris, true ) ) { |
| | 970 | $thisval = wp_kses_bad_protocol( $thisval, $allowed_protocols ); |
| | 971 | } |
| 978 | | if (preg_match("%^'([^']*)'(\s+|/?$)%", $attr, $match)) |
| 979 | | // 'value' |
| 980 | | { |
| 981 | | $thisval = $match[1]; |
| 982 | | if ( in_array(strtolower($attrname), $uris) ) |
| 983 | | $thisval = wp_kses_bad_protocol($thisval, $allowed_protocols); |
| 984 | | |
| 985 | | if(false === array_key_exists($attrname, $attrarr)) { |
| 986 | | $attrarr[$attrname] = array ('name' => $attrname, 'value' => $thisval, 'whole' => "$attrname='$thisval'", 'vless' => 'n'); |
| | 973 | if ( false === array_key_exists( $attrname, $attrarr ) ) { |
| | 974 | $attrarr[ $attrname ] = array( 'name' => $attrname, 'value' => $thisval, 'whole' => $scenario[1], 'vless' => 'n' ); |
| | 975 | } |
| | 976 | $working = 1; |
| | 977 | $mode = 0; |
| | 978 | $attr = preg_replace( $scenario[2], '', $attr ); |
| | 979 | break; |
| 994 | | if (preg_match("%^([^\s\"']+)(\s+|/?$)%", $attr, $match)) |
| 995 | | // value |
| 996 | | { |
| 997 | | $thisval = $match[1]; |
| 998 | | if ( in_array(strtolower($attrname), $uris) ) |
| 999 | | $thisval = wp_kses_bad_protocol($thisval, $allowed_protocols); |
| 1000 | | |
| 1001 | | if(false === array_key_exists($attrname, $attrarr)) { |
| 1002 | | $attrarr[$attrname] = array ('name' => $attrname, 'value' => $thisval, 'whole' => "$attrname=\"$thisval\"", 'vless' => 'n'); |
| 1003 | | } |
| 1004 | | // We add quotes to conform to W3C's HTML spec. |
| 1005 | | $working = 1; |
| 1006 | | $mode = 0; |
| 1007 | | $attr = preg_replace("%^[^\s\"']+(\s+|$)%", '', $attr); |
| 1008 | | } |
| 1009 | | |
| 1020 | | if ($mode == 1 && false === array_key_exists($attrname, $attrarr)) |
| 1021 | | // special case, for when the attribute list ends with a valueless |
| 1022 | | // attribute like "selected" |
| 1023 | | $attrarr[$attrname] = array ('name' => $attrname, 'value' => '', 'whole' => $attrname, 'vless' => 'y'); |
| | 992 | // special case, for when the attribute list ends with a valueless |
| | 993 | // attribute like "selected" |
| | 994 | if ( 1 === $mode && false === array_key_exists( $attrname, $attrarr ) ) { |
| | 995 | $attrarr[ $attrname ] = array( 'name' => $attrname, 'value' => '', 'whole' => $attrname, 'vless' => 'y' ); |
| | 996 | } |