Changes from branches/3.9/src/wp-includes/class-wp-customize-widgets.php at r29389 to trunk/src/wp-includes/class-wp-customize-widgets.php at r28143
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-customize-widgets.php
r29389 r28143 1120 1120 1121 1121 /** 1122 * Get MAC for a serialized widget instance string. 1123 * 1124 * Allows values posted back from JS to be rejected if any tampering of the 1125 * data has occurred. 1122 * Get a widget instance's hash key. 1123 * 1124 * Serialize an instance and hash it with the AUTH_KEY; when a JS value is 1125 * posted back to save, this instance hash key is used to ensure that the 1126 * serialized_instance was not tampered with, but that it had originated 1127 * from WordPress and so is sanitized. 1126 1128 * 1127 1129 * @since 3.9.0 1128 1130 * @access protected 1129 1131 * 1130 * @param string $serialized_instance Widget instance. 1131 * @return string MAC for serialized widget instance. 1132 */ 1133 protected function get_instance_hash_key( $serialized_instance ) { 1134 return wp_hash( $serialized_instance ); 1132 * @param array $instance Widget instance. 1133 * @return string Widget instance's hash key. 1134 */ 1135 protected function get_instance_hash_key( $instance ) { 1136 $hash = md5( AUTH_KEY . serialize( $instance ) ); 1137 return $hash; 1135 1138 } 1136 1139 … … 1160 1163 1161 1164 $decoded = base64_decode( $value['encoded_serialized_instance'], true ); 1165 1162 1166 if ( false === $decoded ) { 1163 1167 return null; 1164 1168 } 1165 1166 if ( $this->get_instance_hash_key( $decoded ) !== $value['instance_hash_key'] ) {1167 return null;1168 }1169 1170 1169 $instance = unserialize( $decoded ); 1170 1171 1171 if ( false === $instance ) { 1172 1172 return null; 1173 1173 } 1174 1174 if ( $this->get_instance_hash_key( $instance ) !== $value['instance_hash_key'] ) { 1175 return null; 1176 } 1175 1177 return $instance; 1176 1178 } … … 1193 1195 'title' => empty( $value['title'] ) ? '' : $value['title'], 1194 1196 'is_widget_customizer_js_value' => true, 1195 'instance_hash_key' => $this->get_instance_hash_key( $ serialized),1197 'instance_hash_key' => $this->get_instance_hash_key( $value ), 1196 1198 ); 1197 1199 }
Note: See TracChangeset
for help on using the changeset viewer.