Changeset 63709
- Timestamp:
- 09/17/2026 09:07:58 PM (2 months ago)
- Location:
- branches/5.3
- Files:
-
- 11 edited
-
. (modified) (1 prop)
-
src/js/_enqueues/wp/theme.js (modified) (2 diffs)
-
src/wp-admin/includes/ajax-actions.php (modified) (2 diffs)
-
src/wp-admin/includes/class-custom-image-header.php (modified) (4 diffs)
-
src/wp-admin/includes/plugin.php (modified) (1 diff)
-
src/wp-admin/includes/post.php (modified) (1 diff)
-
src/wp-includes/class-wp-xmlrpc-server.php (modified) (1 diff)
-
src/wp-includes/customize/class-wp-customize-header-image-setting.php (modified) (2 diffs)
-
src/wp-includes/formatting.php (modified) (1 diff)
-
src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php (modified) (3 diffs)
-
src/wp-includes/theme.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/5.3
- Property svn:mergeinfo changed
/trunk merged: 62658,63656-63657,63659-63660,63665,63669,63672,63675
- Property svn:mergeinfo changed
-
branches/5.3/src/js/_enqueues/wp/theme.js
r45557 r63709 1917 1917 1918 1918 1919 /* 1920 * jQuery.escapeSelector() (added in jQuery 3.0) is not available on this 1921 * branch's vendored jQuery. Fall back to the native CSS.escape(), which is 1922 * what jQuery.escapeSelector() delegates to and which jQuery UI polyfills 1923 * it with. A browser with neither skips the preview route below rather 1924 * than building a selector from an unescaped slug. 1925 */ 1926 var escapeSelector = $.escapeSelector || ( window.CSS && window.CSS.escape && function( sel ) { 1927 return window.CSS.escape( sel + '' ); 1928 } ); 1929 1919 1930 themes.RunInstaller = { 1920 1931 … … 1979 1990 self.view.collection.trigger( 'update' ); 1980 1991 1981 // Open the theme preview. 1992 // Open the theme preview. The slug comes from the URL, so escape it. 1982 1993 self.view.collection.once( 'query:success', function() { 1983 $( 'div[data-slug="' + slug + '"]' ).trigger( 'click' ); 1994 if ( ! escapeSelector ) { 1995 return; 1996 } 1997 1998 $( 'div.theme[data-slug="' + escapeSelector( slug ) + '"]' ).trigger( 'click' ); 1984 1999 }); 1985 2000 -
branches/5.3/src/wp-admin/includes/ajax-actions.php
r56877 r63709 1948 1948 check_ajax_referer( 'getpermalink', 'getpermalinknonce' ); 1949 1949 $post_id = isset( $_POST['post_id'] ) ? intval( $_POST['post_id'] ) : 0; 1950 if ( ! $post_id ) { 1951 // Bypass call to get_preview_post_link() for unspecified post ID. 1952 wp_die( '' ); 1953 } 1954 if ( ! current_user_can( 'edit_post', $post_id ) ) { 1955 wp_die( -1 ); 1956 } 1950 1957 wp_die( get_preview_post_link( $post_id ) ); 1951 1958 } … … 1959 1966 check_ajax_referer( 'samplepermalink', 'samplepermalinknonce' ); 1960 1967 $post_id = isset( $_POST['post_id'] ) ? intval( $_POST['post_id'] ) : 0; 1961 $title = isset( $_POST['new_title'] ) ? $_POST['new_title'] : ''; 1962 $slug = isset( $_POST['new_slug'] ) ? $_POST['new_slug'] : null; 1968 if ( ! $post_id ) { 1969 // Bypass call to get_sample_permalink_html() for unspecified post ID. 1970 wp_die( '' ); 1971 } 1972 if ( ! current_user_can( 'edit_post', $post_id ) ) { 1973 wp_die( -1 ); 1974 } 1975 $title = isset( $_POST['new_title'] ) ? $_POST['new_title'] : ''; 1976 $slug = isset( $_POST['new_slug'] ) ? $_POST['new_slug'] : null; 1963 1977 wp_die( get_sample_permalink_html( $post_id, $title, $slug ) ); 1964 1978 } -
branches/5.3/src/wp-admin/includes/class-custom-image-header.php
r49393 r63709 529 529 } 530 530 ?> 531 <div id="headimg" style="<?php echo $header_image_style; ?>">531 <div id="headimg" style="<?php echo esc_attr( $header_image_style ); ?>"> 532 532 <?php 533 533 if ( display_header_text() ) { … … 1088 1088 'url' => $choice['url'], 1089 1089 'thumbnail_url' => $choice['url'], 1090 'height' => $choice['height'],1091 'width' => $choice['width'],1090 'height' => absint( $choice['height'] ), 1091 'width' => absint( $choice['width'] ), 1092 1092 ); 1093 1093 … … 1117 1117 } 1118 1118 1119 set_theme_mod( 'header_image', esc_url_raw( $header_image_data['url'] ) ); 1119 $header_image_data['url'] = esc_url_raw( $header_image_data['url'] ); 1120 1121 if ( isset( $header_image_data['thumbnail_url'] ) ) { 1122 $header_image_data['thumbnail_url'] = esc_url_raw( $header_image_data['thumbnail_url'] ); 1123 } 1124 1125 set_theme_mod( 'header_image', $header_image_data['url'] ); 1120 1126 set_theme_mod( 'header_image_data', $header_image_data ); 1121 1127 } … … 1478 1484 1479 1485 foreach ( $header_images as &$header_image ) { 1480 $header_meta = get_post_meta( $header_image['attachment_id'] ); 1481 $header_image['timestamp'] = isset( $header_meta[ $timestamp_key ] ) ? $header_meta[ $timestamp_key ] : ''; 1482 $header_image['alt_text'] = isset( $header_meta[ $alt_text_key ] ) ? $header_meta[ $alt_text_key ] : ''; 1486 $header_image['timestamp'] = get_post_meta( $header_image['attachment_id'], $timestamp_key, true ); 1487 $header_image['alt_text'] = get_post_meta( $header_image['attachment_id'], $alt_text_key, true ); 1483 1488 } 1484 1489 -
branches/5.3/src/wp-admin/includes/plugin.php
r46869 r63709 576 576 * 577 577 * @since 3.0.0 578 * 579 * @param string $plugin Path to the plugin file relative to the plugins directory. 578 * @since 7.1.1 The `$plugin` path is normalized with `plugin_basename()` and `trim()`, 579 * matching how `activate_plugin()` resolves it. 580 * 581 * @param string $plugin Path to the plugin file. Accepts a path relative to the plugins 582 * directory, or an absolute path, with or without surrounding whitespace. 580 583 * @return bool True if plugin is network only, false otherwise. 581 584 */ 582 585 function is_network_only_plugin( $plugin ) { 586 // Normalize the path the same way activate_plugin() does, so both agree on the file. 587 $plugin = plugin_basename( trim( $plugin ) ); 588 583 589 $plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); 584 590 if ( $plugin_data ) { -
branches/5.3/src/wp-admin/includes/post.php
r54562 r63709 22 22 if ( empty( $post_data ) ) { 23 23 $post_data = &$_POST; 24 } 25 26 /* 27 * A raw `ID` on the create path (no `post_ID`) is an attempt to overwrite an 28 * existing post while bypassing the per-post capability checks below, which only 29 * run on the update path. Reject it outright: legitimate post creation never 30 * carries an `ID`. 31 */ 32 if ( ! $update && ! empty( $post_data['ID'] ) ) { 33 if ( 'page' === $post_data['post_type'] ) { 34 return new WP_Error( 'edit_others_pages', __( 'Sorry, you are not allowed to edit pages as this user.' ) ); 35 } else { 36 return new WP_Error( 'edit_others_posts', __( 'Sorry, you are not allowed to edit posts as this user.' ) ); 37 } 24 38 } 25 39 -
branches/5.3/src/wp-includes/class-wp-xmlrpc-server.php
r49393 r63709 1391 1391 } 1392 1392 1393 // Reject writes to internal-only builtin post types (e.g. customize_changeset) 1394 // whose intended write path is a dedicated helper, not a generic post API. 1395 $is_internal_only = ( 1396 empty( $post_type->public ) 1397 && empty( $post_type->show_in_rest ) 1398 && ! empty( $post_type->_builtin ) 1399 ); 1400 1401 /** 1402 * Filters whether a post type accepts writes via XML-RPC. 1403 * 1404 * Defaults to false for internal-only builtin post types (public=false, 1405 * show_in_rest=false, _builtin=true), such as customize_changeset, whose 1406 * writes are meant to flow through dedicated helpers. Return true to opt 1407 * a post type back in. 1408 * 1409 * @since 7.1.1 1410 * 1411 * @param bool $allowed Whether the post type accepts XML-RPC writes. 1412 * @param WP_Post_Type $post_type The post type object. 1413 */ 1414 $allowed = apply_filters( 'xmlrpc_allow_post_type_writes', ! $is_internal_only, $post_type ); 1415 1416 if ( ! $allowed ) { 1417 return new IXR_Error( 403, __( 'Sorry, this post type is not supported over XML-RPC.' ) ); 1418 } 1419 1393 1420 $update = ! empty( $post_data['ID'] ); 1394 1421 -
branches/5.3/src/wp-includes/customize/class-wp-customize-header-image-setting.php
r45654 r63709 16 16 * 17 17 * @see WP_Customize_Setting 18 * 19 * @phpstan-type Header_Image_Data array{ 20 * attachment_id?: int, 21 * url?: string, 22 * thumbnail_url?: string, 23 * timestamp?: int, 24 * width?: int, 25 * height?: int, 26 * alt_text?: string, 27 * attachment_parent?: int, 28 * } 18 29 */ 19 30 final class WP_Customize_Header_Image_Setting extends WP_Customize_Setting { … … 51 62 } 52 63 } 64 65 /** 66 * Sanitizes a header value. 67 * 68 * The value is expected to be one of the following: 69 * 70 * - An array of header image data, with the keys `attachment_id`, `url`, `thumbnail_url`, `timestamp`, `width`, 71 * `height`, `alt_text`, and `attachment_parent`, as supplied by {@see get_uploaded_header_images()}. Any other 72 * key is discarded. 73 * - An array with a `choice` key, being the legacy format in which any of the other accepted values is nested. 74 * - The string `remove-header`, `random-default-image`, or `random-uploaded-image`. 75 * - A string corresponding to one of the keys for the array returned by {@see get_uploaded_header_images()}, or 76 * one of the keys for the array passed into {@see register_default_headers()}. 77 * 78 * @since 7.1.1 79 * 80 * @see WP_Customize_Header_Image_Setting::update() 81 * @see Custom_Image_Header::set_header_image() 82 * 83 * @param mixed $value Value to sanitize. 84 * @return array|string|WP_Error|null Sanitized value, or `null`/`WP_Error` if invalid. The array holds 85 * the header image data, or that data nested under a `choice` key, 86 * before the `customize_sanitize_header_image_data` filter, which 87 * may return anything, is applied to it. 88 * 89 * @phpstan-return array<mixed, mixed>|string|WP_Error|null 90 */ 91 public function sanitize( $value ) { 92 /* 93 * The update() method unwraps the legacy `choice` format before handing the value off to 94 * Custom_Image_Header::set_header_image(), so the nested value is what must be sanitized. 95 */ 96 if ( is_array( $value ) && isset( $value['choice'] ) ) { 97 $choice = $this->sanitize_choice( $value['choice'] ); 98 if ( is_null( $choice ) || is_wp_error( $choice ) ) { 99 return $choice; 100 } 101 $value = array( 'choice' => $choice ); 102 } else { 103 $value = $this->sanitize_choice( $value ); 104 if ( is_null( $value ) || is_wp_error( $value ) ) { 105 return $value; 106 } 107 } 108 109 return parent::sanitize( $value ); 110 } 111 112 /** 113 * Sanitizes a header image choice. 114 * 115 * This is the value which is ultimately passed to {@see Custom_Image_Header::set_header_image()}, whether 116 * supplied at the top level of the setting value or nested under its legacy `choice` key. 117 * 118 * @since 7.1.1 119 * 120 * @param mixed $value Value to sanitize. 121 * @return array|string|WP_Error|null Sanitized value, or `null`/`WP_Error` if invalid. 122 * 123 * @phpstan-return Header_Image_Data|string|WP_Error|null 124 */ 125 private function sanitize_choice( $value ) { 126 // Custom_Image_Header::set_header_image() accepts an object in place of an array. 127 if ( is_object( $value ) ) { 128 $value = (array) $value; 129 } 130 131 if ( is_string( $value ) ) { 132 return sanitize_text_field( $value ); 133 } 134 135 if ( ! is_array( $value ) ) { 136 return null; 137 } 138 139 /* 140 * The sanitized value is assembled member by member rather than filtered down from the 141 * supplied one, so that nothing but the members below can end up in it. 142 */ 143 $sanitized = array(); 144 145 if ( isset( $value['attachment_id'] ) ) { 146 if ( ! is_scalar( $value['attachment_id'] ) ) { 147 return null; 148 } 149 $attachment_id = absint( $value['attachment_id'] ); 150 151 /* 152 * A supplied attachment must be an existing image, since its ID is written to postmeta and its 153 * data displayed. Note that an ID of zero must be skipped rather than looked up, as 154 * get_post_mime_type() falls back to the global post when passed an empty value. 155 */ 156 if ( $attachment_id > 0 ) { 157 $mime_type = get_post_mime_type( $attachment_id ); 158 if ( ! is_string( $mime_type ) || ! str_starts_with( $mime_type, 'image/' ) ) { 159 return null; 160 } 161 } 162 163 $sanitized['attachment_id'] = $attachment_id; 164 } 165 166 if ( isset( $value['url'] ) ) { 167 if ( ! is_string( $value['url'] ) ) { 168 return null; 169 } 170 $sanitized['url'] = esc_url_raw( $value['url'] ); 171 if ( '' === $sanitized['url'] ) { 172 return new WP_Error( 'invalid_url', __( 'Invalid URL.' ) ); 173 } 174 } 175 176 if ( isset( $value['thumbnail_url'] ) ) { 177 if ( ! is_string( $value['thumbnail_url'] ) ) { 178 return null; 179 } 180 $sanitized['thumbnail_url'] = esc_url_raw( $value['thumbnail_url'] ); 181 if ( '' === $sanitized['thumbnail_url'] ) { 182 return new WP_Error( 'invalid_url', __( 'Invalid URL.' ) ); 183 } 184 } 185 186 if ( isset( $value['timestamp'] ) ) { 187 if ( ! is_scalar( $value['timestamp'] ) ) { 188 return null; 189 } 190 $sanitized['timestamp'] = absint( $value['timestamp'] ); 191 } 192 193 if ( isset( $value['width'] ) ) { 194 if ( ! is_scalar( $value['width'] ) ) { 195 return null; 196 } 197 $sanitized['width'] = absint( $value['width'] ); 198 } 199 200 if ( isset( $value['height'] ) ) { 201 if ( ! is_scalar( $value['height'] ) ) { 202 return null; 203 } 204 $sanitized['height'] = absint( $value['height'] ); 205 } 206 207 if ( isset( $value['alt_text'] ) ) { 208 if ( ! is_string( $value['alt_text'] ) ) { 209 return null; 210 } 211 $sanitized['alt_text'] = sanitize_text_field( $value['alt_text'] ); 212 } 213 214 if ( isset( $value['attachment_parent'] ) ) { 215 if ( ! is_scalar( $value['attachment_parent'] ) ) { 216 return null; 217 } 218 $sanitized['attachment_parent'] = absint( $value['attachment_parent'] ); 219 } 220 221 return $sanitized; 222 } 53 223 } -
branches/5.3/src/wp-includes/formatting.php
r55788 r63709 570 570 571 571 // If a <blockquote> is wrapped with a <p>, move it inside the <blockquote>. 572 $pee = preg_replace( ' |<p><blockquote([^>]*)>|i', '<blockquote$1><p>', $pee );572 $pee = preg_replace( '!<p><blockquote((?:[^>"\']|"[^"]*"|\'[^\']*\')*)>!i', '<blockquote$1><p>', $pee ); 573 573 $pee = str_replace( '</blockquote></p>', '</p></blockquote>', $pee ); 574 574 -
branches/5.3/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php
r46433 r63709 666 666 * 667 667 * @since 4.7.0 668 * @since 7.1.0 Target post permissions are checked when a comment's parent post is changed. 668 669 * 669 670 * @param WP_REST_Request $request Full details about the request. … … 678 679 if ( ! $this->check_edit_permission( $comment ) ) { 679 680 return new WP_Error( 'rest_cannot_edit', __( 'Sorry, you are not allowed to edit this comment.' ), array( 'status' => rest_authorization_required_code() ) ); 681 } 682 683 /* 684 * check_edit_permission() above only establishes that the comment may be 685 * edited where it currently sits, because 'edit_comment' maps to 'edit_post' 686 * on the comment's current parent. When the parent is being changed, the new 687 * parent has to be authorized as well. Without this, a user holding 688 * edit_comment on their own comment could reparent it onto any post, 689 * including posts they can neither read nor edit. 690 */ 691 if ( isset( $request['post'] ) && (int) $request['post'] !== (int) $comment->comment_post_ID ) { 692 $target_check = $this->check_target_post_permission( (int) $request['post'] ); 693 694 if ( is_wp_error( $target_check ) ) { 695 return $target_check; 696 } 680 697 } 681 698 … … 1708 1725 return $email; 1709 1726 } 1727 1728 /** 1729 * Checks that a post can receive a comment from the current user. 1730 * 1731 * Used when changing the parent post of an existing comment, so that 1732 * attaching a comment to a post is authorized the same way whichever 1733 * path it arrives by. 1734 * 1735 * @since 7.1.0 1736 * 1737 * @param int $post_id Target post ID. 1738 * @return true|WP_Error True if the post can receive the comment, error object otherwise. 1739 */ 1740 protected function check_target_post_permission( $post_id ) { 1741 if ( ! $post_id ) { 1742 return new WP_Error( 1743 'rest_comment_invalid_post_id', 1744 __( 'Sorry, you are not allowed to create this comment without a post.' ), 1745 array( 'status' => 403 ) 1746 ); 1747 } 1748 1749 /* 1750 * A comment needs either comment moderation rights or edit access to the 1751 * post, which is what check_edit_permission() grants on the post a comment 1752 * is moving away from. Requiring the same at the destination means both 1753 * ends of a move are authorized alike. 1754 */ 1755 if ( ! current_user_can( 'moderate_comments' ) && ! current_user_can( 'edit_post', $post_id ) ) { 1756 return new WP_Error( 1757 'rest_cannot_edit', 1758 __( 'Sorry, you are not allowed to edit this comment.' ), 1759 array( 'status' => rest_authorization_required_code() ) 1760 ); 1761 } 1762 1763 $post = get_post( $post_id ); 1764 1765 if ( ! $post ) { 1766 return new WP_Error( 1767 'rest_comment_invalid_post_id', 1768 __( 'Sorry, you are not allowed to create this comment without a post.' ), 1769 array( 'status' => 403 ) 1770 ); 1771 } 1772 1773 /* 1774 * The create-time draft and comments-open rules are deliberately not applied 1775 * here, because moderators move comments onto posts whose discussion has 1776 * closed and onto drafts today. Enforcing them would break that without 1777 * blocking anything the capability check above already permits. 1778 */ 1779 return true; 1780 } 1710 1781 } -
branches/5.3/src/wp-includes/theme.php
r46457 r63709 1319 1319 * 1320 1320 * @since 3.4.0 1321 * @since 7.1.1 The `width` and `height` are cast to non-negative integers. 1321 1322 * 1322 1323 * @global array $_wp_default_headers … … 1357 1358 'video' => get_theme_support( 'custom-header', 'video' ), 1358 1359 ); 1359 return (object) wp_parse_args( $data, $default ); 1360 1361 if ( ! is_array( $data ) && ! is_object( $data ) ) { 1362 $data = array(); 1363 } 1364 $header = (object) wp_parse_args( $data, $default ); 1365 $header->width = absint( $header->width ); 1366 $header->height = absint( $header->height ); 1367 return $header; 1360 1368 } 1361 1369
Note:
See TracChangeset
for help on using the changeset viewer.