<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[13471] trunk/wp-admin/options.php: Make it more obvious we'
 re escaping values in options.php.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/13471">13471</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2010-02-27 22:50:00 +0000 (Sat, 27 Feb 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Make it more obvious we're escaping values in options.php. fixes <a href="http://trac.wordpress.org/ticket/12417">#12417</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminoptionsphp">trunk/wp-admin/options.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminoptionsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/options.php (13470 => 13471)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/options.php        2010-02-27 22:01:22 UTC (rev 13470)
+++ trunk/wp-admin/options.php        2010-02-27 22:50:00 UTC (rev 13471)
</span><span class="lines">@@ -152,24 +152,23 @@
</span><span class="cx"> 
</span><span class="cx"> &lt;div class=&quot;wrap&quot;&gt;
</span><span class="cx"> &lt;?php screen_icon(); ?&gt;
</span><del>-  &lt;h2&gt;&lt;?php _e('All Settings'); ?&gt;&lt;/h2&gt;
</del><ins>+  &lt;h2&gt;&lt;?php esc_html_e('All Settings'); ?&gt;&lt;/h2&gt;
</ins><span class="cx">   &lt;form name=&quot;form&quot; action=&quot;options.php&quot; method=&quot;post&quot; id=&quot;all-options&quot;&gt;
</span><span class="cx">   &lt;?php wp_nonce_field('options-options') ?&gt;
</span><span class="cx">   &lt;input type=&quot;hidden&quot; name=&quot;action&quot; value=&quot;update&quot; /&gt;
</span><span class="cx">   &lt;input type='hidden' name='option_page' value='options' /&gt;
</span><span class="cx">   &lt;table class=&quot;form-table&quot;&gt;
</span><span class="cx"> &lt;?php
</span><del>-$options = $wpdb-&gt;get_results(&quot;SELECT * FROM $wpdb-&gt;options ORDER BY option_name&quot;);
</del><ins>+$options = $wpdb-&gt;get_results( &quot;SELECT * FROM $wpdb-&gt;options ORDER BY option_name&quot; );
</ins><span class="cx"> 
</span><del>-foreach ( (array) $options as $option) :
</del><ins>+foreach ( (array) $options as $option ) :
</ins><span class="cx">         $disabled = '';
</span><del>-        $option-&gt;option_name = esc_attr($option-&gt;option_name);
</del><span class="cx">         if ( $option-&gt;option_name == '' )
</span><span class="cx">                 continue;
</span><del>-        if ( is_serialized($option-&gt;option_value) ) {
-                if ( is_serialized_string($option-&gt;option_value) ) {
</del><ins>+        if ( is_serialized( $option-&gt;option_value ) ) {
+                if ( is_serialized_string( $option-&gt;option_value ) ) {
</ins><span class="cx">                         // this is a serialized string, so we should display it
</span><del>-                        $value = maybe_unserialize($option-&gt;option_value);
</del><ins>+                        $value = maybe_unserialize( $option-&gt;option_value );
</ins><span class="cx">                         $options_to_update[] = $option-&gt;option_name;
</span><span class="cx">                         $class = 'all-options';
</span><span class="cx">                 } else {
</span><span class="lines">@@ -182,21 +181,21 @@
</span><span class="cx">                 $options_to_update[] = $option-&gt;option_name;
</span><span class="cx">                 $class = 'all-options';
</span><span class="cx">         }
</span><ins>+        $name = esc_attr( $option-&gt;option_name );
</ins><span class="cx">         echo &quot;
</span><span class="cx"> &lt;tr&gt;
</span><del>-        &lt;th scope='row'&gt;&lt;label for='$option-&gt;option_name'&gt;$option-&gt;option_name&lt;/label&gt;&lt;/th&gt;
</del><ins>+        &lt;th scope='row'&gt;&lt;label for='$'&gt;&quot; . esc_html( $option-&gt;option_name ) . &quot;&lt;/label&gt;&lt;/th&gt;
</ins><span class="cx"> &lt;td&gt;&quot;;
</span><del>-
-        if (strpos($value, &quot;\n&quot;) !== false) echo &quot;&lt;textarea class='$class' name='$option-&gt;option_name' id='$option-&gt;option_name' cols='30' rows='5'&gt;&quot; . esc_html($value) . &quot;&lt;/textarea&gt;&quot;;
-        else echo &quot;&lt;input class='regular-text $class' type='text' name='$option-&gt;option_name' id='$option-&gt;option_name' value='&quot; . esc_attr($value) . &quot;'$disabled /&gt;&quot;;
-
</del><ins>+        if ( strpos( $value, &quot;\n&quot; ) !== false )
+                echo &quot;&lt;textarea class='$class' name='$name' id='$name' cols='30' rows='5'&gt;&quot; . wp_htmledit_pre( $value ) . &quot;&lt;/textarea&gt;&quot;;
+        else
+                echo &quot;&lt;input class='regular-text $class' type='text' name='$name' id='$name' value='&quot; . esc_attr( $value ) . &quot;'$disabled /&gt;&quot;;
</ins><span class="cx">         echo &quot;&lt;/td&gt;
</span><span class="cx"> &lt;/tr&gt;&quot;;
</span><span class="cx"> endforeach;
</span><span class="cx"> ?&gt;
</span><span class="cx">   &lt;/table&gt;
</span><del>-&lt;?php $options_to_update = implode(',', $options_to_update); ?&gt;
-&lt;p class=&quot;submit&quot;&gt;&lt;input type=&quot;hidden&quot; name=&quot;page_options&quot; value=&quot;&lt;?php echo esc_attr($options_to_update); ?&gt;&quot; /&gt;&lt;input type=&quot;submit&quot; name=&quot;Update&quot; value=&quot;&lt;?php _e('Save Changes') ?&gt;&quot; class=&quot;button-primary&quot; /&gt;&lt;/p&gt;
</del><ins>+&lt;p class=&quot;submit&quot;&gt;&lt;input type=&quot;hidden&quot; name=&quot;page_options&quot; value=&quot;&lt;?php echo esc_attr( implode( ',', $options_to_update ) ); ?&gt;&quot; /&gt;&lt;input type=&quot;submit&quot; name=&quot;Update&quot; value=&quot;&lt;?php esc_attr_e( 'Save Changes' ); ?&gt;&quot; class=&quot;button-primary&quot; /&gt;&lt;/p&gt;
</ins><span class="cx">   &lt;/form&gt;
</span><span class="cx"> &lt;/div&gt;
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>