Changeset 59120
- Timestamp:
- 09/30/2024 05:17:54 AM (12 days ago)
- Location:
- trunk
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/js/_enqueues/lib/link.js
r58450 r59120 324 324 325 325 if ( attrs.target ) { 326 html += ' rel="noopener"target="' + attrs.target + '"';326 html += ' target="' + attrs.target + '"'; 327 327 } 328 328 -
trunk/src/js/_enqueues/vendor/tinymce/plugins/wplink/plugin.js
r58146 r59120 5 5 return ( 6 6 '<div id="' + this._id + '" class="wp-link-preview">' + 7 '<a href="' + this.url + '" target="_blank" rel="noopener"tabindex="-1">' + this.url + '</a>' +7 '<a href="' + this.url + '" target="_blank" tabindex="-1">' + this.url + '</a>' + 8 8 '</div>' 9 9 ); -
trunk/src/wp-admin/includes/class-wp-site-health.php
r58913 r59120 747 747 ), 748 748 'actions' => sprintf( 749 '<p><a href="%s" target="_blank" rel="noopener">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',749 '<p><a href="%s" target="_blank">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>', 750 750 esc_url( wp_get_update_php_url() ), 751 751 __( 'Learn more about updating PHP' ), … … 893 893 /* translators: Localized team handbook, if one exists. */ 894 894 esc_url( __( 'https://make.wordpress.org/hosting/handbook/handbook/server-environment/#php-extensions' ) ), 895 'target="_blank" rel="noopener"',895 'target="_blank"', 896 896 sprintf( 897 897 '<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span>', … … 1219 1219 ), 1220 1220 'actions' => sprintf( 1221 '<p><a href="%s" target="_blank" rel="noopener">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',1221 '<p><a href="%s" target="_blank">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>', 1222 1222 /* translators: Localized version of WordPress requirements if one exists. */ 1223 1223 esc_url( __( 'https://wordpress.org/about/requirements/' ) ), … … 1336 1336 1337 1337 $result['actions'] = sprintf( 1338 '<p><a href="%s" target="_blank" rel="noopener">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',1338 '<p><a href="%s" target="_blank">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>', 1339 1339 /* translators: Localized Support reference. */ 1340 1340 esc_url( __( 'https://wordpress.org/support/forums/' ) ), … … 1374 1374 ), 1375 1375 'actions' => sprintf( 1376 '<p><a href="%s" target="_blank" rel="noopener">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',1376 '<p><a href="%s" target="_blank">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>', 1377 1377 /* translators: Documentation explaining debugging in WordPress. */ 1378 1378 esc_url( __( 'https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/' ) ), … … 1456 1456 ), 1457 1457 'actions' => sprintf( 1458 '<p><a href="%s" target="_blank" rel="noopener">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',1458 '<p><a href="%s" target="_blank">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>', 1459 1459 esc_url( $default_update_url ), 1460 1460 __( 'Learn more about why you should use HTTPS' ), … … 1540 1540 if ( ! empty( $direct_update_url ) ) { 1541 1541 $result['actions'] = sprintf( 1542 '<p class="button-container"><a class="button button-primary" href="%1$s" target="_blank" rel="noopener">%2$s<span class="screen-reader-text"> %3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',1542 '<p class="button-container"><a class="button button-primary" href="%1$s" target="_blank">%2$s<span class="screen-reader-text"> %3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>', 1543 1543 esc_url( $direct_update_url ), 1544 1544 __( 'Update your site to use HTTPS' ), … … 1559 1559 if ( $update_url !== $default_update_url ) { 1560 1560 $result['description'] .= sprintf( 1561 '<p><a href="%s" target="_blank" rel="noopener">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',1561 '<p><a href="%s" target="_blank">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>', 1562 1562 esc_url( $update_url ), 1563 1563 __( 'Talk to your web host about supporting HTTPS for your website.' ), … … 2365 2365 } else { 2366 2366 $result['actions'] .= sprintf( 2367 '<p><a href="%s" target="_blank" rel="noopener">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',2367 '<p><a href="%s" target="_blank">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>', 2368 2368 __( 'https://developer.wordpress.org/rest-api/frequently-asked-questions/#why-is-authentication-not-working' ), 2369 2369 __( 'Learn how to configure the Authorization header.' ), … … 2398 2398 'label' => '', 2399 2399 'actions' => sprintf( 2400 '<p><a href="%1$s" target="_blank" rel="no opener noreferrer">%2$s<span class="screen-reader-text"> %3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',2400 '<p><a href="%1$s" target="_blank" rel="noreferrer">%2$s<span class="screen-reader-text"> %3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>', 2401 2401 __( 'https://developer.wordpress.org/advanced-administration/performance/optimization/#caching' ), 2402 2402 __( 'Learn more about page cache' ), … … 2524 2524 ), 2525 2525 'actions' => sprintf( 2526 '<p><a href="%s" target="_blank" rel="noopener">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',2526 '<p><a href="%s" target="_blank">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>', 2527 2527 esc_url( $action_url ), 2528 2528 __( 'Learn more about persistent object caching.' ), … … 2672 2672 $result['actions'] = sprintf( 2673 2673 /* translators: 1: HelpHub URL, 2: Link description. */ 2674 '<p><a target="_blank" rel="noopener"href="%1$s">%2$s</a></p>',2674 '<p><a target="_blank" href="%1$s">%2$s</a></p>', 2675 2675 esc_url( __( 'https://developer.wordpress.org/advanced-administration/performance/optimization/#autoloaded-options' ) ), 2676 2676 __( 'More info about optimizing autoloaded options' ) -
trunk/src/wp-admin/includes/dashboard.php
r58975 r59120 1913 1913 <?php 1914 1914 printf( 1915 '<a class="button button-primary" href="%1$s" target="_blank" rel="noopener">%2$s<span class="screen-reader-text"> %3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',1915 '<a class="button button-primary" href="%1$s" target="_blank">%2$s<span class="screen-reader-text"> %3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>', 1916 1916 esc_url( wp_get_update_php_url() ), 1917 1917 __( 'Learn more about updating PHP' ), -
trunk/src/wp-admin/includes/media.php
r58373 r59120 3244 3244 /* translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations. */ 3245 3245 esc_url( __( 'https://www.w3.org/WAI/tutorials/images/decision-tree/' ) ), 3246 'target="_blank" rel="noopener"',3246 'target="_blank"', 3247 3247 sprintf( 3248 3248 '<span class="screen-reader-text"> %s</span>', -
trunk/src/wp-includes/class-walker-nav-menu.php
r56067 r59120 216 216 $atts['title'] = ! empty( $menu_item->attr_title ) ? $menu_item->attr_title : ''; 217 217 $atts['target'] = ! empty( $menu_item->target ) ? $menu_item->target : ''; 218 if ( '_blank' === $menu_item->target && empty( $menu_item->xfn ) ) { 219 $atts['rel'] = 'noopener'; 220 } else { 221 $atts['rel'] = $menu_item->xfn; 222 } 218 $atts['rel'] = ! empty( $menu_item->xfn ) ? $menu_item->xfn : ''; 223 219 224 220 if ( ! empty( $menu_item->url ) ) { -
trunk/src/wp-includes/comment.php
r59039 r59120 3767 3767 $value = get_comment_link( $comment->comment_ID ); 3768 3768 $value = sprintf( 3769 '<a href="%s" target="_blank" rel="noopener">%s</a>',3769 '<a href="%s" target="_blank">%s</a>', 3770 3770 esc_url( $value ), 3771 3771 esc_html( $value ) -
trunk/src/wp-includes/default-filters.php
r59083 r59120 153 153 add_filter( $filter, 'balanceTags', 50 ); 154 154 } 155 156 // Add proper rel values for links with target.157 add_action( 'init', 'wp_init_targeted_link_rel_filters' );158 155 159 156 // Format strings for display. -
trunk/src/wp-includes/formatting.php
r58889 r59120 3295 3295 * @since 5.1.0 3296 3296 * @since 5.6.0 Removed 'noreferrer' relationship. 3297 * @deprecated 6.7.0 3297 3298 * 3298 3299 * @param string $text Content that may contain HTML A elements. … … 3300 3301 */ 3301 3302 function wp_targeted_link_rel( $text ) { 3303 _deprecated_function( __FUNCTION__, '6.7.0' ); 3304 3302 3305 // Don't run (more expensive) regex if no links with targets. 3303 3306 if ( stripos( $text, 'target' ) === false || stripos( $text, '<a ' ) === false || is_serialized( $text ) ) { … … 3333 3336 * @since 5.1.0 3334 3337 * @since 5.6.0 Removed 'noreferrer' relationship. 3338 * @deprecated 6.7.0 3335 3339 * 3336 3340 * @param array $matches Single match. … … 3338 3342 */ 3339 3343 function wp_targeted_link_rel_callback( $matches ) { 3344 _deprecated_function( __FUNCTION__, '6.7.0' ); 3345 3340 3346 $link_html = $matches[1]; 3341 3347 $original_link_html = $link_html; … … 3384 3390 * 3385 3391 * @since 5.1.0 3392 * @deprecated 6.7.0 3386 3393 */ 3387 3394 function wp_init_targeted_link_rel_filters() { 3388 $filters = array( 3389 'title_save_pre', 3390 'content_save_pre', 3391 'excerpt_save_pre', 3392 'content_filtered_save_pre', 3393 'pre_comment_content', 3394 'pre_term_description', 3395 'pre_link_description', 3396 'pre_link_notes', 3397 'pre_user_description', 3398 ); 3399 3400 foreach ( $filters as $filter ) { 3401 add_filter( $filter, 'wp_targeted_link_rel' ); 3402 } 3395 _deprecated_function( __FUNCTION__, '6.7.0' ); 3403 3396 } 3404 3397 … … 3407 3400 * 3408 3401 * @since 5.1.0 3402 * @deprecated 6.7.0 3409 3403 */ 3410 3404 function wp_remove_targeted_link_rel_filters() { 3411 $filters = array( 3412 'title_save_pre', 3413 'content_save_pre', 3414 'excerpt_save_pre', 3415 'content_filtered_save_pre', 3416 'pre_comment_content', 3417 'pre_term_description', 3418 'pre_link_description', 3419 'pre_link_notes', 3420 'pre_user_description', 3421 ); 3422 3423 foreach ( $filters as $filter ) { 3424 remove_filter( $filter, 'wp_targeted_link_rel' ); 3425 } 3405 _deprecated_function( __FUNCTION__, '6.7.0' ); 3426 3406 } 3427 3407 -
trunk/src/wp-includes/functions.php
r59107 r59120 8518 8518 echo '<p class="button-container">'; 8519 8519 printf( 8520 '<a class="button button-primary" href="%1$s" target="_blank" rel="noopener">%2$s<span class="screen-reader-text"> %3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',8520 '<a class="button button-primary" href="%1$s" target="_blank">%2$s<span class="screen-reader-text"> %3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>', 8521 8521 esc_url( $direct_update_url ), 8522 8522 __( 'Update PHP' ), -
trunk/src/wp-includes/media-template.php
r58947 r59120 162 162 /* translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations. */ 163 163 esc_url( __( 'https://www.w3.org/WAI/tutorials/images/decision-tree/' ) ), 164 'target="_blank" rel="noopener"',164 'target="_blank"', 165 165 sprintf( 166 166 '<span class="screen-reader-text"> %s</span>', -
trunk/src/wp-includes/widgets/class-wp-widget-custom-html.php
r56196 r59120 149 149 /** This filter is documented in wp-includes/widgets/class-wp-widget-text.php */ 150 150 $content = apply_filters( 'widget_text', $instance['content'], $simulated_text_widget_instance, $this ); 151 152 // Adds 'noopener' relationship, without duplicating values, to all HTML A elements that have a target.153 $content = wp_targeted_link_rel( $content );154 151 155 152 /** -
trunk/src/wp-includes/widgets/class-wp-widget-media-image.php
r56690 r59120 289 289 $link .= $image; 290 290 $link .= '</a>'; 291 $image = wp_targeted_link_rel( $link );291 $image = $link; 292 292 } 293 293 -
trunk/src/wp-includes/widgets/class-wp-widget-text.php
r56597 r59120 335 335 $text = preg_replace_callback( '#<(video|iframe|object|embed)\s[^>]*>#i', array( $this, 'inject_video_max_width_style' ), $text ); 336 336 337 // Adds 'noopener' relationship, without duplicating values, to all HTML A elements that have a target.338 $text = wp_targeted_link_rel( $text );339 340 337 ?> 341 338 <div class="textwidget"><?php echo $text; ?></div> -
trunk/src/wp-login.php
r59027 r59120 698 698 699 699 printf( 700 '<a href="%s" rel="noopener"target="_blank">%s%s</a>',700 '<a href="%s" target="_blank">%s%s</a>', 701 701 esc_url( $admin_email_help_url ), 702 702 __( 'Why is this important?' ), … … 1630 1630 if ( links[i].href ) { 1631 1631 links[i].target = '_blank'; 1632 links[i].rel = 'noopener';1633 1632 } 1634 1633 } -
trunk/tests/phpunit/tests/formatting/wpTargetedLinkRel.php
r56547 r59120 1 <?php2 3 /**4 * @group formatting5 * @ticket 431876 *7 * @covers ::wp_targeted_link_rel8 */9 class Tests_Formatting_wpTargetedLinkRel extends WP_UnitTestCase {10 11 public function test_add_to_links_with_target_blank() {12 $content = '<p>Links: <a href="/" target="_blank">No rel</a></p>';13 $expected = '<p>Links: <a href="/" target="_blank" rel="noopener">No rel</a></p>';14 $this->assertSame( $expected, wp_targeted_link_rel( $content ) );15 }16 17 public function test_add_to_links_with_target_foo() {18 $content = '<p>Links: <a href="/" target="foo">No rel</a></p>';19 $expected = '<p>Links: <a href="/" target="foo" rel="noopener">No rel</a></p>';20 $this->assertSame( $expected, wp_targeted_link_rel( $content ) );21 }22 23 public function test_target_as_first_attribute() {24 $content = '<p>Links: <a target="_blank" href="#">No rel</a></p>';25 $expected = '<p>Links: <a target="_blank" href="#" rel="noopener">No rel</a></p>';26 $this->assertSame( $expected, wp_targeted_link_rel( $content ) );27 }28 29 public function test_add_to_existing_rel() {30 $content = '<p>Links: <a href="/" rel="existing values" target="_blank">Existing rel</a></p>';31 $expected = '<p>Links: <a href="/" rel="existing values noopener" target="_blank">Existing rel</a></p>';32 $this->assertSame( $expected, wp_targeted_link_rel( $content ) );33 }34 35 public function test_no_duplicate_values_added() {36 $content = '<p>Links: <a href="/" rel="existing noopener values" target="_blank">Existing rel</a></p>';37 $expected = '<p>Links: <a href="/" rel="existing noopener values" target="_blank">Existing rel</a></p>';38 $this->assertSame( $expected, wp_targeted_link_rel( $content ) );39 }40 41 public function test_rel_with_single_quote_delimiter() {42 $content = '<p>Links: <a href="/" rel=\'existing values\' target="_blank">Existing rel</a></p>';43 $expected = '<p>Links: <a href="/" rel="existing values noopener" target="_blank">Existing rel</a></p>';44 $this->assertSame( $expected, wp_targeted_link_rel( $content ) );45 }46 47 public function test_rel_with_no_delimiter() {48 $content = '<p>Links: <a href="/" rel=existing target="_blank">Existing rel</a></p>';49 $expected = '<p>Links: <a href="/" rel="existing noopener" target="_blank">Existing rel</a></p>';50 $this->assertSame( $expected, wp_targeted_link_rel( $content ) );51 }52 53 public function test_rel_value_spaced_and_no_delimiter() {54 $content = '<p>Links: <a href="/" rel = existing target="_blank">Existing rel</a></p>';55 $expected = '<p>Links: <a href="/" rel="existing noopener" target="_blank">Existing rel</a></p>';56 $this->assertSame( $expected, wp_targeted_link_rel( $content ) );57 }58 59 public function test_escaped_quotes() {60 $content = '<p>Links: <a href=\"/\" rel=\"existing values\" target=\"_blank\">Existing rel</a></p>';61 $expected = '<p>Links: <a href=\"/\" rel=\"existing values noopener\" target=\"_blank\">Existing rel</a></p>';62 $this->assertSame( $expected, wp_targeted_link_rel( $content ) );63 }64 65 public function test_ignore_links_with_no_target() {66 $content = '<p>Links: <a href="/" target="_blank">Change me</a> <a href="/">Do not change me</a></p>';67 $expected = '<p>Links: <a href="/" target="_blank" rel="noopener">Change me</a> <a href="/">Do not change me</a></p>';68 $this->assertSame( $expected, wp_targeted_link_rel( $content ) );69 }70 71 /**72 * Ensure empty rel attributes are not added.73 *74 * @ticket 4535275 */76 public function test_ignore_if_wp_targeted_link_rel_nulled() {77 add_filter( 'wp_targeted_link_rel', '__return_empty_string' );78 $content = '<p>Links: <a href="/" target="_blank">Do not change me</a></p>';79 $expected = '<p>Links: <a href="/" target="_blank">Do not change me</a></p>';80 $this->assertSame( $expected, wp_targeted_link_rel( $content ) );81 }82 83 /**84 * Ensure default content filters are added.85 *86 * @ticket 4529287 */88 public function test_wp_targeted_link_rel_filters_run() {89 $content = '<p>Links: <a href="/" target="_blank">No rel</a></p>';90 $expected = '<p>Links: <a href="/" target="_blank" rel="noopener">No rel</a></p>';91 92 $post = self::factory()->post->create_and_get(93 array(94 'post_content' => $content,95 )96 );97 98 $this->assertSame( $expected, $post->post_content );99 }100 101 /**102 * Ensure JSON format is preserved when relation attribute (rel) is missing.103 *104 * @ticket 46316105 */106 public function test_wp_targeted_link_rel_should_preserve_json() {107 $content = '<p>Links: <a href=\"\/\" target=\"_blank\">No rel<\/a><\/p>';108 $expected = '<p>Links: <a href=\"\/\" target=\"_blank\" rel=\"noopener\">No rel<\/a><\/p>';109 $this->assertSame( $expected, wp_targeted_link_rel( $content ) );110 }111 112 /**113 * Ensure the content of style and script tags are not processed114 *115 * @ticket 47244116 */117 public function test_wp_targeted_link_rel_skips_style_and_scripts() {118 $content = '<style><a href="/" target=a></style><p>Links: <script>console.log("<a href=\'/\' target=a>hi</a>");</script><script>alert(1);</script>here <a href="/" target=_blank>aq</a></p><script>console.log("<a href=\'last\' target=\'_blank\'")</script>';119 $expected = '<style><a href="/" target=a></style><p>Links: <script>console.log("<a href=\'/\' target=a>hi</a>");</script><script>alert(1);</script>here <a href="/" target="_blank" rel="noopener">aq</a></p><script>console.log("<a href=\'last\' target=\'_blank\'")</script>';120 $this->assertSame( $expected, wp_targeted_link_rel( $content ) );121 }122 123 /**124 * Ensure entirely serialized content is ignored.125 *126 * @ticket 46402127 */128 public function test_ignore_entirely_serialized_content() {129 $content = 'a:1:{s:4:"html";s:52:"<p>Links: <a href="/" target="_blank">No Rel</a></p>";}';130 $expected = 'a:1:{s:4:"html";s:52:"<p>Links: <a href="/" target="_blank">No Rel</a></p>";}';131 $this->assertSame( $expected, wp_targeted_link_rel( $content ) );132 }133 134 public function test_wp_targeted_link_rel_tab_separated_values_are_split() {135 $content = "<p>Links: <a href=\"/\" target=\"_blank\" rel=\"ugc\t\tnoopener\t\">No rel</a></p>";136 $expected = '<p>Links: <a href="/" target="_blank" rel="ugc noopener">No rel</a></p>';137 $this->assertSame( $expected, wp_targeted_link_rel( $content ) );138 }139 } -
trunk/tests/phpunit/tests/menu/walker-nav-menu.php
r56559 r59120 44 44 45 45 /** 46 * Tests when an item's target is _blank, that rel="noopener" is added.47 *48 * @ticket 4329049 */50 public function test_noopener_no_referrer_for_target_blank() {51 $actual = '';52 $post_id = self::factory()->post->create();53 $post_title = get_the_title( $post_id );54 55 $item = array(56 'ID' => $post_id,57 'object_id' => $post_id,58 'title' => $post_title,59 'target' => '_blank',60 'xfn' => '',61 'current' => false,62 );63 64 $args = array(65 'before' => '',66 'after' => '',67 'link_before' => '',68 'link_after' => '',69 );70 71 $this->walker->start_el( $actual, (object) $item, 0, (object) $args );72 73 $this->assertSame( "<li id=\"menu-item-{$post_id}\" class=\"menu-item-{$post_id}\"><a target=\"_blank\" rel=\"noopener\">{$post_title}</a>", $actual );74 }75 76 /**77 46 * @ticket 47720 78 47 * … … 219 188 ), 220 189 'no xfn value and a target of "_blank"' => array( 221 'expected' => 'rel=" noopenerprivacy-policy"',190 'expected' => 'rel="privacy-policy"', 222 191 'xfn' => '', 223 192 'target' => '_blank', -
trunk/tests/phpunit/tests/rest-api/rest-attachments-controller.php
r59034 r59120 1444 1444 ), 1445 1445 'description' => array( 1446 'raw' => '<a href="#" target="_blank" rel="noopener">link</a>',1447 'rendered' => '<p><a href="#" target="_blank" rel="noopener">link</a></p>',1446 'raw' => '<a href="#" target="_blank">link</a>', 1447 'rendered' => '<p><a href="#" target="_blank">link</a></p>', 1448 1448 ), 1449 1449 'caption' => array( 1450 'raw' => '<a href="#" target="_blank" rel="noopener">link</a>',1451 'rendered' => '<p><a href="#" target="_blank" rel="noopener">link</a></p>',1450 'raw' => '<a href="#" target="_blank">link</a>', 1451 'rendered' => '<p><a href="#" target="_blank">link</a></p>', 1452 1452 ), 1453 1453 ), -
trunk/tests/phpunit/tests/rest-api/rest-posts-controller.php
r59115 r59120 4286 4286 ), 4287 4287 'content' => array( 4288 'raw' => '<a href="#" target="_blank" rel="noopener">link</a>',4289 'rendered' => '<p><a href="#" target="_blank" rel="noopener">link</a></p>',4288 'raw' => '<a href="#" target="_blank">link</a>', 4289 'rendered' => '<p><a href="#" target="_blank">link</a></p>', 4290 4290 ), 4291 4291 'excerpt' => array( 4292 'raw' => '<a href="#" target="_blank" rel="noopener">link</a>',4293 'rendered' => '<p><a href="#" target="_blank" rel="noopener">link</a></p>',4292 'raw' => '<a href="#" target="_blank">link</a>', 4293 'rendered' => '<p><a href="#" target="_blank">link</a></p>', 4294 4294 ), 4295 4295 ), -
trunk/tests/phpunit/tests/widgets/wpWidgetCustomHtml.php
r56547 r59120 304 304 305 305 /** 306 * Ensure that rel="noopener" is added to links witha target.306 * Ensure that rel="noopener" is not added to links without a target. 307 307 * 308 308 * @ticket 46421 309 309 */ 310 public function test_render_links_with _target() {311 $widget = new WP_Widget_Custom_HTML(); 312 313 $content = 'Test content with an external <a href="https://example.org" target="_blank">link</a>.';310 public function test_render_links_without_target() { 311 $widget = new WP_Widget_Custom_HTML(); 312 313 $content = 'Test content with an internal <a href="/">link</a>.'; 314 314 315 315 $args = array( … … 326 326 327 327 $output = get_echo( array( $widget, 'widget' ), array( $args, $instance ) ); 328 $this->assertStringContainsString( 'rel="noopener"', $output );329 }330 331 /**332 * Ensure that rel="noopener" is not added to links without a target.333 *334 * @ticket 46421335 */336 public function test_render_links_without_target() {337 $widget = new WP_Widget_Custom_HTML();338 339 $content = 'Test content with an internal <a href="/">link</a>.';340 341 $args = array(342 'before_title' => '<h2>',343 'after_title' => '</h2>',344 'before_widget' => '',345 'after_widget' => '',346 );347 348 $instance = array(349 'title' => 'Foo',350 'content' => $content,351 );352 353 $output = get_echo( array( $widget, 'widget' ), array( $args, $instance ) );354 328 $this->assertStringNotContainsString( 'rel="noopener"', $output ); 355 329 } -
trunk/tests/phpunit/tests/widgets/wpWidgetMediaImage.php
r57987 r59120 545 545 $this->assertStringContainsString( '<a href="https://example.org"', $output ); 546 546 $this->assertStringContainsString( 'target="_blank"', $output ); 547 $this->assertStringContainsString( 'rel="noopener"', $output );548 547 549 548 // Populate caption in attachment. -
trunk/tests/phpunit/tests/widgets/wpWidgetText.php
r56549 r59120 1003 1003 1004 1004 /** 1005 * Ensure that rel="noopener" is added to links witha target.1005 * Ensure that rel="noopener" is not added to links without a target. 1006 1006 * 1007 1007 * @ticket 46421 1008 1008 */ 1009 public function test_render_links_with _target() {1009 public function test_render_links_without_target() { 1010 1010 $widget = new WP_Widget_Text(); 1011 1011 1012 $text = 'Test content with an external <a href="https://example.org" target="_blank">link</a>.';1012 $text = 'Test content with an internal <a href="/">link</a>.'; 1013 1013 1014 1014 $args = array( … … 1026 1026 $output = get_echo( array( $widget, 'widget' ), array( $args, $instance ) ); 1027 1027 1028 $this->assertStringContainsString( 'rel="noopener"', $output );1029 }1030 1031 /**1032 * Ensure that rel="noopener" is not added to links without a target.1033 *1034 * @ticket 464211035 */1036 public function test_render_links_without_target() {1037 $widget = new WP_Widget_Text();1038 1039 $text = 'Test content with an internal <a href="/">link</a>.';1040 1041 $args = array(1042 'before_title' => '<h2>',1043 'after_title' => '</h2>',1044 'before_widget' => '',1045 'after_widget' => '',1046 );1047 1048 $instance = array(1049 'title' => 'Foo',1050 'text' => $text,1051 );1052 1053 $output = get_echo( array( $widget, 'widget' ), array( $args, $instance ) );1054 1055 1028 $this->assertStringNotContainsString( 'rel="noopener"', $output ); 1056 1029 }
Note: See TracChangeset
for help on using the changeset viewer.