Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Creating a new test + data provider and a filter to add a port number…
… to the test host domain.
  • Loading branch information
ramonjd committed Dec 2, 2021
commit 7ae4c781efa3c0631de86d7d690ef0a42be4f0a6
37 changes: 35 additions & 2 deletions tests/phpunit/tests/kses.php
Original file line number Diff line number Diff line change
Expand Up @@ -1600,17 +1600,50 @@ function data_wp_kses_object_tag_allowed() {
'<object type="application/pdf" data="/cat/foo.pdf" />',
'',
),
'url with port number' => array(
);
}

/**
* Test that uploaded object tags with port numbers in the URL.
*
* @ticket 54261
*
* @dataProvider data_wp_kses_object_data_url_with_port_number_allowed
*
* @param string $html A string of HTML to test.
* @param string $expected The expected result from KSES.
*/
function test_wp_kses_object_data_url_with_port_number_allowed( $html, $expected ) {
add_filter( 'upload_dir', array( $this, 'wp_kses_upload_dir_filter' ), 10, 2 );
$this->assertSame( $expected, wp_kses_post( $html ) );
remove_filter( 'upload_dir', array( $this, 'wp_kses_upload_dir_filter' ), 10, 2 );
}

/**
* Data provider for test_wp_kses_object_data_url_with_port_number_allowed().
*/
function data_wp_kses_object_data_url_with_port_number_allowed() {
return array(
'url with port number' => array(
'<object type="application/pdf" data="https://example.org:8888/cat/foo.pdf" />',
'<object type="application/pdf" data="https://example.org:8888/cat/foo.pdf" />',
),
'url with port number-like path' => array(
'url with port number and http protocol' => array(
'<object type="application/pdf" data="http://example.org:8888/cat/foo.pdf" />',
'<object type="application/pdf" data="http://example.org:8888/cat/foo.pdf" />',
),
'url with port number-like path' => array(
'<object type="application/pdf" data="https://example.org/cat:8888/foo.pdf" />',
'<object type="application/pdf" data="https://example.org/cat:8888/foo.pdf" />',
),
);
}

public function wp_kses_upload_dir_filter( $param ) {
$param['port'] = 8888;
return $param;
}

/**
* Test that object tags will continue to function if they've been added using the
* 'wp_kses_allowed_html' filter.
Expand Down