Make WordPress Core


Ignore:
Timestamp:
12/12/2019 06:17:35 PM (5 years ago)
Author:
whyisjake
Message:

Ensure that a user can publish_posts before making a post sticky.

Props: danielbachhuber, whyisjake, peterwilson, xknown.

Prevent stored XSS through wp_targeted_link_rel().

Props: vortfu, whyisjake, peterwilsoncc, xknown, SergeyBiryukov, flaviozavan.

Update wp_kses_bad_protocol() to recognize : on uri attributes,

wp_kses_bad_protocol() makes sure to validate that uri attributes don’t contain invalid/or not allowed protocols. While this works fine in most cases, there’s a risk that by using the colon html5 named entity, one is able to bypass this function.

Brings r46895 to the 5.3 branch.

Props: xknown, nickdaugherty, peterwilsoncc.

Prevent stored XSS in the block editor.

Brings r46896 to the 5.3 branch.

Prevent escaped unicode characters become unescaped in unsafe HTML during JSON decoding.

Props: aduth, epiqueras.

Location:
branches/5.2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.2

  • branches/5.2/tests/phpunit/tests/formatting/WPTargetedLinkRel.php

    r45349 r46901  
    3939    public function test_rel_with_single_quote_delimiter() {
    4040        $content  = '<p>Links: <a href="/" rel=\'existing values\' target="_blank">Existing rel</a></p>';
    41         $expected = '<p>Links: <a href="/" rel=\'existing values noopener noreferrer\' target="_blank">Existing rel</a></p>';
     41        $expected = '<p>Links: <a href="/" rel="existing values noopener noreferrer" target="_blank">Existing rel</a></p>';
    4242        $this->assertEquals( $expected, wp_targeted_link_rel( $content ) );
    4343    }
     
    5252        $content  = '<p>Links: <a href="/" rel = existing target="_blank">Existing rel</a></p>';
    5353        $expected = '<p>Links: <a href="/" rel="existing noopener noreferrer" target="_blank">Existing rel</a></p>';
    54         $this->assertEquals( $expected, wp_targeted_link_rel( $content ) );
    55     }
    56 
    57     public function test_rel_value_spaced_and_no_delimiter_and_values_to_escape() {
    58         $content  = '<p>Links: <a href="/" rel = existing"value target="_blank">Existing rel</a></p>';
    59         $expected = '<p>Links: <a href="/" rel="existing&quot;value noopener noreferrer" target="_blank">Existing rel</a></p>';
    6054        $this->assertEquals( $expected, wp_targeted_link_rel( $content ) );
    6155    }
     
    115109
    116110    /**
    117      * Ensure correct quotes are used when relation attribute (rel) is missing.
     111     * Ensure the content of style and script tags are not processed
    118112     *
    119113     * @ticket 47244
    120114     */
    121     public function test_wp_targeted_link_rel_should_use_correct_quotes() {
    122         $content  = '<p>Links: <a href=\'\/\' target=\'_blank\'>No rel<\/a><\/p>';
    123         $expected = '<p>Links: <a href=\'\/\' target=\'_blank\' rel=\'noopener noreferrer\'>No rel<\/a><\/p>';
    124         $this->assertEquals( $expected, wp_targeted_link_rel( $content ) );
    125 
    126         $content  = '<p>Links: <a href=\'\/\' target=_blank>No rel<\/a><\/p>';
    127         $expected = '<p>Links: <a href=\'\/\' target=_blank rel=\'noopener noreferrer\'>No rel<\/a><\/p>';
     115    public function test_wp_targeted_link_rel_skips_style_and_scripts() {
     116        $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>';
     117        $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 noreferrer">aq</a></p><script>console.log("<a href=\'last\' target=\'_blank\'")</script>';
    128118        $this->assertEquals( $expected, wp_targeted_link_rel( $content ) );
    129119    }
     120
     121    /**
     122     * Ensure entirely serialized content is ignored.
     123     *
     124     * @ticket 46402
     125     */
     126    public function test_ignore_entirely_serialized_content() {
     127        $content  = 'a:1:{s:4:"html";s:52:"<p>Links: <a href="/" target="_blank">No Rel</a></p>";}';
     128        $expected = 'a:1:{s:4:"html";s:52:"<p>Links: <a href="/" target="_blank">No Rel</a></p>";}';
     129        $this->assertEquals( $expected, wp_targeted_link_rel( $content ) );
     130    }
     131
     132    public function test_wp_targeted_link_rel_tab_separated_values_are_split() {
     133        $content  = "<p>Links: <a href=\"/\" target=\"_blank\" rel=\"ugc\t\tnoopener\t\">No rel</a></p>";
     134        $expected = '<p>Links: <a href="/" target="_blank" rel="ugc noopener noreferrer">No rel</a></p>';
     135        $this->assertEquals( $expected, wp_targeted_link_rel( $content ) );
     136    }
     137
    130138}
Note: See TracChangeset for help on using the changeset viewer.