| 66 | /** |
| 67 | * Test video tag. |
| 68 | * |
| 69 | * @ticket 50167 |
| 70 | * @dataProvider data_wp_kses_video |
| 71 | * |
| 72 | * @param string $source Source HTML. |
| 73 | * @param string $context Context to use for parsing source. |
| 74 | * @param string $expected Expected output following KSES parsing. |
| 75 | * @return void |
| 76 | */ |
| 77 | function test_wp_kses_video( $source, $context, $expected ) { |
| 78 | $actual = wp_kses( $source, $context ); |
| 79 | $this->assertSame( $expected, $actual ); |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * Data provider for test_wp_kses_video |
| 84 | * |
| 85 | * @return array[] Array containing test data { |
| 86 | * @type string $source Source HTML. |
| 87 | * @type string $context Context to use for parsing source. |
| 88 | * @type string $expected Expected output following KSES parsing. |
| 89 | * } |
| 90 | */ |
| 91 | function data_wp_kses_video() { |
| 92 | return array( |
| 93 | // Set 0: Valid post object params in post context. |
| 94 | array( |
| 95 | '<video src="movie.mov" autoplay controls height=9 loop muted poster="still.mov" playsinline preload width=16 />', |
| 96 | 'post', |
| 97 | '<video src="movie.mov" autoplay controls height="9" loop muted poster="still.mov" playsinline preload width="16" />', |
| 98 | ), |
| 99 | // Set 1: Valid post object params in data context. |
| 100 | array( |
| 101 | '<video src="movie.mov" autoplay controls height=9 loop muted poster="still.mov" playsinline preload width=16 />', |
| 102 | 'data', |
| 103 | '', |
| 104 | ), |
| 105 | // Set 2: Disallowed urls in post context. |
| 106 | array( |
| 107 | '<video src="bad://w.org/movie.mov" poster="bad://w.org/movie.jpg" />', |
| 108 | 'post', |
| 109 | '<video src="//w.org/movie.mov" poster="//w.org/movie.jpg" />', |
| 110 | ), |
| 111 | // Set 3: Disallowed attributes in post context. |
| 112 | array( |
| 113 | '<video onload="alert(1);" src="https://videos.files.wordpress.com/DZEMDKxc/video-0f9c363010.mp4" />', |
| 114 | 'post', |
| 115 | '<video src="https://videos.files.wordpress.com/DZEMDKxc/video-0f9c363010.mp4" />', |
| 116 | ), |
| 117 | ); |
| 118 | } |
| 119 | |