Skip to content
Open
Changes from all commits
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
46 changes: 46 additions & 0 deletions WordPress/Docs/Security/EscapeOutputStandard.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0"?>
<documentation title="Escape Output">
<standard>
<![CDATA[
Dynamic output must be escaped.

This sniff checks that any dynamic data sent to the browser
is escaped using a WordPress escaping function, such as
esc_html(), esc_attr(), or wp_kses_post(). Escaping prevents
cross-site scripting (XSS) vulnerabilities and ensures
output is safe.
]]>
</standard>

<code_comparison>
<code title="Invalid: unescaped echo">
<![CDATA[
<?php
$name = $_GET['name'];
echo <em>$name</em>;
]]>
</code>
<code title="Valid: escaped echo">
<![CDATA[
<?php
$name = $_GET['name'];
echo <em>esc_html( $name )</em>;
]]>
</code>
</code_comparison>

<code_comparison>
<code title="Invalid: unescaped printf">
<![CDATA[
<?php
printf( 'Hello %s', <em>$name</em> );
]]>
</code>
<code title="Valid: escaped printf">
<![CDATA[
<?php
printf( 'Hello %s', <em>esc_html( $name )</em> );
]]>
</code>
</code_comparison>
</documentation>
Loading