Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #62885, comment 1


Ignore:
Timestamp:
01/30/2025 04:14:41 PM (11 months ago)
Author:
sabernhardt
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #62885, comment 1

    initial v1  
    1 Exmple
     1Example
     2{{{
    23function custom_message_shortcode() {
    34
     
    1011}
    1112add_shortcode('custom_message', 'custom_message_shortcode');
     13}}}
    1214
    13 This line of code uses preg_replace() to sanitize a string by removing potentially unsafe event handler attributes (like onclick, onmouseover, etc.) from HTML elements.
     15This line of code uses `preg_replace()` to sanitize a string by removing potentially unsafe event handler attributes (like `onclick`, `onmouseover`, etc.) from HTML elements.
    1416
    1517This is a security measure to prevent malicious JavaScript from being executed via event handler attributes in user-supplied content. It helps mitigate risks like Cross-Site Scripting (XSS).
     
    2123
    2224
    23 so preg_replace( '/\s*on\w+\s*=\s*["\']?.*?["\']?/i', '', $safe_text ); line
     25so `preg_replace( '/\s*on\w+\s*=\s*["\']?.*?["\']?/i', '', $safe_text );` line
    2426sanitized and escaped html