Changeset 58097 for trunk/tests/phpunit/tests/kses.php
- Timestamp:
- 05/04/2024 07:23:31 PM (4 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/kses.php
r57987 r58097 1733 1733 return array( 1734 1734 'valid value for type' => array( 1735 '<object type="application/pdf" data="https:// example.org/foo.pdf" />',1736 '<object type="application/pdf" data="https:// example.org/foo.pdf" />',1735 '<object type="application/pdf" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" />', 1736 '<object type="application/pdf" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" />', 1737 1737 ), 1738 1738 'invalid value for type' => array( 1739 '<object type="application/exe" data="https:// example.org/foo.exe" />',1739 '<object type="application/exe" data="https://' . WP_TESTS_DOMAIN . '/foo.exe" />', 1740 1740 '', 1741 1741 ), 1742 1742 'multiple type attributes, last invalid' => array( 1743 '<object type="application/pdf" type="application/exe" data="https:// example.org/foo.pdf" />',1744 '<object type="application/pdf" data="https:// example.org/foo.pdf" />',1743 '<object type="application/pdf" type="application/exe" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" />', 1744 '<object type="application/pdf" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" />', 1745 1745 ), 1746 1746 'multiple type attributes, first uppercase, last invalid' => array( 1747 '<object TYPE="application/pdf" type="application/exe" data="https:// example.org/foo.pdf" />',1748 '<object TYPE="application/pdf" data="https:// example.org/foo.pdf" />',1747 '<object TYPE="application/pdf" type="application/exe" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" />', 1748 '<object TYPE="application/pdf" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" />', 1749 1749 ), 1750 1750 'multiple type attributes, last upper case and invalid' => array( 1751 '<object type="application/pdf" TYPE="application/exe" data="https:// example.org/foo.pdf" />',1752 '<object type="application/pdf" data="https:// example.org/foo.pdf" />',1751 '<object type="application/pdf" TYPE="application/exe" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" />', 1752 '<object type="application/pdf" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" />', 1753 1753 ), 1754 1754 'multiple type attributes, first invalid' => array( 1755 '<object type="application/exe" type="application/pdf" data="https:// example.org/foo.pdf" />',1755 '<object type="application/exe" type="application/pdf" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" />', 1756 1756 '', 1757 1757 ), 1758 1758 'multiple type attributes, first upper case and invalid' => array( 1759 '<object TYPE="application/exe" type="application/pdf" data="https:// example.org/foo.pdf" />',1759 '<object TYPE="application/exe" type="application/pdf" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" />', 1760 1760 '', 1761 1761 ), 1762 1762 'multiple type attributes, first invalid, last uppercase' => array( 1763 '<object type="application/exe" TYPE="application/pdf" data="https:// example.org/foo.pdf" />',1763 '<object type="application/exe" TYPE="application/pdf" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" />', 1764 1764 '', 1765 1765 ), 1766 1766 'multiple object tags, last invalid' => array( 1767 '<object type="application/pdf" data="https:// example.org/foo.pdf" /><object type="application/exe" data="https://example.org/foo.exe" />',1768 '<object type="application/pdf" data="https:// example.org/foo.pdf" />',1767 '<object type="application/pdf" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" /><object type="application/exe" data="https://' . WP_TESTS_DOMAIN . '/foo.exe" />', 1768 '<object type="application/pdf" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" />', 1769 1769 ), 1770 1770 'multiple object tags, first invalid' => array( 1771 '<object type="application/exe" data="https:// example.org/foo.exe" /><object type="application/pdf" data="https://example.org/foo.pdf" />',1772 '<object type="application/pdf" data="https:// example.org/foo.pdf" />',1771 '<object type="application/exe" data="https://' . WP_TESTS_DOMAIN . '/foo.exe" /><object type="application/pdf" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" />', 1772 '<object type="application/pdf" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" />', 1773 1773 ), 1774 1774 'type attribute with partially incorrect value' => array( 1775 '<object type="application/pdfa" data="https:// example.org/foo.pdf" />',1775 '<object type="application/pdfa" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" />', 1776 1776 '', 1777 1777 ), 1778 1778 'type attribute with empty value' => array( 1779 '<object type="" data="https:// example.org/foo.pdf" />',1779 '<object type="" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" />', 1780 1780 '', 1781 1781 ), 1782 1782 'type attribute with no value' => array( 1783 '<object type data="https:// example.org/foo.pdf" />',1783 '<object type data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" />', 1784 1784 '', 1785 1785 ), 1786 1786 'no type attribute' => array( 1787 '<object data="https:// example.org/foo.pdf" />',1787 '<object data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" />', 1788 1788 '', 1789 1789 ), 1790 1790 'different protocol in url' => array( 1791 '<object type="application/pdf" data="http:// example.org/foo.pdf" />',1792 '<object type="application/pdf" data="http:// example.org/foo.pdf" />',1791 '<object type="application/pdf" data="http://' . WP_TESTS_DOMAIN . '/foo.pdf" />', 1792 '<object type="application/pdf" data="http://' . WP_TESTS_DOMAIN . '/foo.pdf" />', 1793 1793 ), 1794 1794 'query string on url' => array( 1795 '<object type="application/pdf" data="https:// example.org/foo.pdf?lol=.pdf" />',1795 '<object type="application/pdf" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf?lol=.pdf" />', 1796 1796 '', 1797 1797 ), 1798 1798 'fragment on url' => array( 1799 '<object type="application/pdf" data="https:// example.org/foo.pdf#lol.pdf" />',1799 '<object type="application/pdf" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf#lol.pdf" />', 1800 1800 '', 1801 1801 ), 1802 1802 'wrong extension' => array( 1803 '<object type="application/pdf" data="https:// example.org/foo.php" />',1803 '<object type="application/pdf" data="https://' . WP_TESTS_DOMAIN . '/foo.php" />', 1804 1804 '', 1805 1805 ), 1806 1806 'protocol-relative url' => array( 1807 '<object type="application/pdf" data="// example.org/foo.pdf" />',1807 '<object type="application/pdf" data="//' . WP_TESTS_DOMAIN . '/foo.pdf" />', 1808 1808 '', 1809 1809 ), 1810 1810 'unsupported protocol' => array( 1811 '<object type="application/pdf" data="ftp:// example.org/foo.pdf" />',1811 '<object type="application/pdf" data="ftp://' . WP_TESTS_DOMAIN . '/foo.pdf" />', 1812 1812 '', 1813 1813 ), … … 1817 1817 ), 1818 1818 'url with port number-like path' => array( 1819 '<object type="application/pdf" data="https:// example.org/cat:8888/foo.pdf" />',1820 '<object type="application/pdf" data="https:// example.org/cat:8888/foo.pdf" />',1819 '<object type="application/pdf" data="https://' . WP_TESTS_DOMAIN . '/cat:8888/foo.pdf" />', 1820 '<object type="application/pdf" data="https://' . WP_TESTS_DOMAIN . '/cat:8888/foo.pdf" />', 1821 1821 ), 1822 1822 ); … … 1869 1869 */ 1870 1870 public function wp_kses_upload_dir_filter( $param ) { 1871 $url_with_port_number = is_string( $param['url'] ) ? str_replace( 'example.org', 'example.org:8888', $param['url'] ) : $param['url']; 1871 // Take care to replace the entire domain, including cases where it already has a port number. 1872 $parsed = parse_url( $param['url'] ); 1873 $replace_domain = $parsed['host']; 1874 if ( isset( $parsed['port'] ) ) { 1875 $replace_domain .= ':' . $parsed['port']; 1876 } 1877 1878 $url_with_port_number = is_string( $param['url'] ) ? str_replace( $replace_domain, 'example.org:8888', $param['url'] ) : $param['url']; 1872 1879 $param['url'] = $url_with_port_number; 1873 1880 return $param;
Note: See TracChangeset
for help on using the changeset viewer.