[wp-trac] [WordPress Trac] #54488: wp_filter_nohtml_kses does not remove HTML comments
WordPress Trac
noreply at wordpress.org
Fri Feb 10 17:27:32 UTC 2023
#54488: wp_filter_nohtml_kses does not remove HTML comments
--------------------------------------+-----------------------
Reporter: leewillis77 | Owner: audrasjb
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: 6.2
Component: Formatting | Version: 2.1
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests | Focuses: docs
--------------------------------------+-----------------------
Changes (by Dharm1025):
* keywords: has-patch has-unit-tests needs-testing => has-patch has-unit-
tests
Comment:
== Test Report
This report validates that the indicated patch addresses the issue.
Patch tested: https://github.com/WordPress/wordpress-develop/pull/3370
=== Environment
* OS: macOS Ventura 13.0
* Web Server: nginx/1.23.3
* PHP: 7.4.33
* WordPress: 6.1-beta2-54337-src
* Browser: Version 109.0.5414.119 (Official Build) (arm64)
* Theme: Twenty Twenty-Three
* Active Plugins: -
=== Test Results
Works as expected with a patch.
Hi @audrasjb, Thanks for the testing instructions. I have tested the patch
as per testing instructions and it works as expected.
**Before Patch:**
{{{#!php
<?php
echo wp_filter_nohtml_kses('<!-- This is a comment --><p>This is not a
comment</p>');
// Output: <!-- This is a comment -->This is not a comment
echo wp_filter_nohtml_kses('<!--This is a comment--><p>This is not a
comment</p>');
// Output: <!--This is a comment-->This is not a comment
echo wp_filter_nohtml_kses('<p>This is not a comment<!-- This is a comment
--></p>');
// Output: This is not a comment<!-- This is a comment -->
echo wp_filter_nohtml_kses('<p>This is not a comment <!-- <a
href="https://wordpress.org">WordPress.org</a> --> </p>');
// Output: This is not a comment <!-- WordPress.org -->
echo wp_filter_nohtml_kses('<p>This is not a comment <!-- This is a
comment</p> -->');
// Output: This is not a comment <!-- This is a comment -->
echo wp_filter_nohtml_kses('<!--
This is a comment
this is a second line
this is a third line
-->This is not a comment');
// Output: <!--
// This is a comment
// this is a second line
// this is a third line
// -->This is not a comment
}}}
**After Patch:**
{{{#!php
<?PHP
echo wp_filter_nohtml_kses('<!-- This is a comment --><p>This is not a
comment</p>');
// Output: This is not a comment
echo wp_filter_nohtml_kses('<!--This is a comment--><p>This is not a
comment</p>');
// Output: This is not a comment
echo wp_filter_nohtml_kses('<p>This is not a comment<!-- This is a comment
--></p>');
// Output: This is not a comment
echo wp_filter_nohtml_kses('<p>This is not a comment <!-- <a
href="https://wordpress.org">WordPress.org</a> --> </p>');
// Output: This is not a comment <!-- WordPress.org -->
echo wp_filter_nohtml_kses('<p>This is not a comment <!-- This is a
comment</p> -->');
// Output: This is not a comment <!-- This is a comment -->
echo wp_filter_nohtml_kses('<!--
This is a comment
this is a second line
this is a third line
-->This is not a comment');
// Output: This is not a comment
}}}
Thanks
--
Ticket URL: <https://core.trac.wordpress.org/ticket/54488#comment:14>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list