Changeset 43981 for trunk/src/wp-includes/kses.php
- Timestamp:
- 12/12/2018 02:38:14 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/5.0 merged: 43727
- Property svn:mergeinfo changed
-
trunk/src/wp-includes/kses.php
r43571 r43981 1077 1077 * 1078 1078 * @since 4.2.3 1079 * @since 5.0.0 Add support for `data-*` wildcard attributes. 1079 1080 * 1080 1081 * @param string $name The attribute name. Passed by reference. Returns empty string when not allowed. … … 1091 1092 $name_low = strtolower( $name ); 1092 1093 if ( ! isset( $allowed_attr[ $name_low ] ) || '' == $allowed_attr[ $name_low ] ) { 1093 $name = $value = $whole = ''; 1094 return false; 1094 /* 1095 * Allow `data-*` attributes. 1096 * 1097 * When specifying `$allowed_html`, the attribute name should be set as 1098 * `data-*` (not to be mixed with the HTML 4.0 `data` attribute, see 1099 * https://www.w3.org/TR/html40/struct/objects.html#adef-data). 1100 * 1101 * Note: the attribute name should only contain `A-Za-z0-9_-` chars, 1102 * double hyphens `--` are not accepted by WordPress. 1103 */ 1104 if ( strpos( $name_low, 'data-' ) === 0 && ! empty( $allowed_attr['data-*'] ) && preg_match( '/^data(?:-[a-z0-9_]+)+$/', $name_low, $match ) ) { 1105 /* 1106 * Add the whole attribute name to the allowed attributes and set any restrictions 1107 * for the `data-*` attribute values for the current element. 1108 */ 1109 $allowed_attr[ $match[0] ] = $allowed_attr['data-*']; 1110 } else { 1111 $name = $value = $whole = ''; 1112 return false; 1113 } 1095 1114 } 1096 1115 … … 2092 2111 * 2093 2112 * @since 3.5.0 2113 * @since 5.0.0 Add support for `data-*` wildcard attributes. 2094 2114 * @access private 2095 2115 * @ignore … … 2100 2120 function _wp_add_global_attributes( $value ) { 2101 2121 $global_attributes = array( 2102 'class' => true, 2103 'id' => true, 2104 'style' => true, 2105 'title' => true, 2106 'role' => true, 2122 'class' => true, 2123 'id' => true, 2124 'style' => true, 2125 'title' => true, 2126 'role' => true, 2127 'data-*' => true, 2107 2128 ); 2108 2129
Note: See TracChangeset
for help on using the changeset viewer.