| 78 | | function test_feed_links() { |
| | 78 | /** |
| | 79 | * @ticket 29807 |
| | 80 | */ |
| | 81 | function test_wp_filter_post_kses_img() { |
| | 82 | global $allowedposttags; |
| | 83 | |
| | 84 | $attributes = array( |
| | 85 | 'class' => 'classname', |
| | 86 | 'id' => 'idattr', |
| | 87 | 'style' => 'color: red;', |
| | 88 | 'alt' => 'alt', |
| | 89 | 'src' => '/test.png', |
| | 90 | 'srcset' => '/test.png 2x', |
| | 91 | 'width' => '100', |
| | 92 | 'height' => '100', |
| | 93 | 'usemap' => '#hash', |
| | 94 | 'vspace' => '20', |
| | 95 | 'hspace' => '20', |
| | 96 | 'longdesc' => 'this is the longdesc', |
| | 97 | 'align' => 'middle', |
| | 98 | 'border' => '5', |
| | 99 | ); |
| | 100 | |
| | 101 | foreach ( $attributes as $name => $value ) { |
| | 102 | if ( $name === $value ) { |
| | 103 | $string = "<img $value />"; |
| | 104 | $expect_string = "<img " . trim( $value, ';' ) . " />"; |
| | 105 | } else { |
| | 106 | $string = "<img $name='$value' />"; |
| | 107 | $expect_string = "<img $name='" . trim( $value, ';' ) . "' />"; |
| | 108 | } |
| | 109 | |
| | 110 | $this->assertEquals( $expect_string, wp_kses( $string, $allowedposttags ) ); |
| | 111 | } |
| | 112 | } |
| | 113 | |
| | 114 | /** |
| | 115 | * @ticket 29807 |
| | 116 | */ |
| | 117 | function test_wp_filter_post_kses_picture() { |
| | 120 | $html = '<picture><source srcset="pear-mobile.jpeg" media="(max-width: 720px)" type="image/png"><source srcset="pear-tablet.jpeg" media="(max-width: 1280px)" type="image/png"><img src="pear-desktop.jpeg" alt="The pear is juicy."></picture>'; |
| | 121 | $this->assertEquals( $html, wp_kses( $html, $allowedposttags ) ); |
| | 122 | |
| | 123 | $html = '<picture><source srcset="https://wordpress.org/pear-mobile.jpeg" media="(max-width: 720px)" type="image/png"><source srcset="https://wordpress.org/pear-tablet.jpeg 500w, https://wordpress.org/pear-tablet.jpeg" media="(max-width: 1280px)" type="image/png"><img src="pear-desktop.jpeg" alt="The pear is juicy."></picture>'; |
| | 124 | $this->assertEquals( $html, wp_kses( $html, $allowedposttags ) ); |
| | 125 | |
| | 126 | // Test bad protocol in srcset |
| | 127 | $original = '<picture><source srcset="bad://pear-mobile.jpeg" media="(max-width: 720px)" type="image/png"><source srcset="pear-tablet.jpeg" media="(max-width: 1280px)" type="image/png"><img src="pear-desktop.jpeg" alt="The pear is juicy."></picture>'; |
| | 128 | $expected = '<picture><source srcset="//pear-mobile.jpeg" media="(max-width: 720px)" type="image/png"><source srcset="pear-tablet.jpeg" media="(max-width: 1280px)" type="image/png"><img src="pear-desktop.jpeg" alt="The pear is juicy."></picture>'; |
| | 129 | $this->assertEquals( $expected, wp_kses( $original, $allowedposttags ) ); |
| | 130 | } |
| | 131 | |
| | 132 | function test_feed_links() { |
| | 133 | global $allowedposttags; |