<!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>[14933] trunk/wp-admin:
  Separate out multiple _ajax_nonce fields on post forms.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/14933">14933</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2010-05-26 04:55:21 +0000 (Wed, 26 May 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Separate out multiple _ajax_nonce fields on post forms. Yay, validation. fixes <a href="http://trac.wordpress.org/ticket/13383">#13383</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminadminajaxphp">trunk/wp-admin/admin-ajax.php</a></li>
<li><a href="#trunkwpadminincludesmetaboxesphp">trunk/wp-admin/includes/meta-boxes.php</a></li>
<li><a href="#trunkwpadminincludestemplatephp">trunk/wp-admin/includes/template.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminadminajaxphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/admin-ajax.php (14932 => 14933)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/admin-ajax.php        2010-05-26 04:36:42 UTC (rev 14932)
+++ trunk/wp-admin/admin-ajax.php        2010-05-26 04:55:21 UTC (rev 14933)
</span><span class="lines">@@ -218,7 +218,7 @@
</span><span class="cx"> function _wp_ajax_add_hierarchical_term() {
</span><span class="cx">         $action = $_POST['action'];
</span><span class="cx">         $taxonomy = get_taxonomy(substr($action, 4));
</span><del>-        check_ajax_referer( $action );
</del><ins>+        check_ajax_referer( $action, '_ajax_nonce-add-' . $taxonomy-&gt;name );
</ins><span class="cx">         if ( !current_user_can( $taxonomy-&gt;cap-&gt;edit_terms ) )
</span><span class="cx">                 die('-1');
</span><span class="cx">         $names = explode(',', $_POST['new'.$taxonomy-&gt;name]);
</span><span class="lines">@@ -702,7 +702,7 @@
</span><span class="cx">         $x-&gt;send();
</span><span class="cx">         break;
</span><span class="cx"> case 'replyto-comment' :
</span><del>-        check_ajax_referer( $action );
</del><ins>+        check_ajax_referer( $action, '_ajax_nonce-replyto-comment' );
</ins><span class="cx"> 
</span><span class="cx">         $comment_post_ID = (int) $_POST['comment_post_ID'];
</span><span class="cx">         if ( !current_user_can( 'edit_post', $comment_post_ID ) )
</span><span class="lines">@@ -771,7 +771,7 @@
</span><span class="cx">         $x-&gt;send();
</span><span class="cx">         break;
</span><span class="cx"> case 'edit-comment' :
</span><del>-        check_ajax_referer( 'replyto-comment' );
</del><ins>+        check_ajax_referer( 'replyto-comment', '_ajax_nonce-replyto-comment' );
</ins><span class="cx"> 
</span><span class="cx">         $comment_post_ID = (int) $_POST['comment_post_ID'];
</span><span class="cx">         if ( ! current_user_can( 'edit_post', $comment_post_ID ) )
</span><span class="lines">@@ -845,7 +845,7 @@
</span><span class="cx">         }
</span><span class="cx">         break;
</span><span class="cx"> case 'add-meta' :
</span><del>-        check_ajax_referer( 'add-meta' );
</del><ins>+        check_ajax_referer( 'add-meta', '_ajax_nonce-add-meta' );
</ins><span class="cx">         $c = 0;
</span><span class="cx">         $pid = (int) $_POST['post_id'];
</span><span class="cx">         $post = get_post( $pid );
</span></span></pre></div>
<a id="trunkwpadminincludesmetaboxesphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/meta-boxes.php (14932 => 14933)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/meta-boxes.php        2010-05-26 04:36:42 UTC (rev 14932)
+++ trunk/wp-admin/includes/meta-boxes.php        2010-05-26 04:55:21 UTC (rev 14933)
</span><span class="lines">@@ -336,7 +336,7 @@
</span><span class="cx">                                         &lt;/label&gt;
</span><span class="cx">                                         &lt;?php wp_dropdown_categories( array( 'taxonomy' =&gt; $taxonomy, 'hide_empty' =&gt; 0, 'name' =&gt; 'new'.$taxonomy.'_parent', 'orderby' =&gt; 'name', 'hierarchical' =&gt; 1, 'show_option_none' =&gt; '&amp;mdash; ' . $tax-&gt;labels-&gt;parent_item . ' &amp;mdash;', 'tab_index' =&gt; 3 ) ); ?&gt;
</span><span class="cx">                                         &lt;input type=&quot;button&quot; id=&quot;&lt;?php echo $taxonomy; ?&gt;-add-submit&quot; class=&quot;add:&lt;?php echo $taxonomy ?&gt;checklist:&lt;?php echo $taxonomy ?&gt;-add button category-add-sumbit&quot; value=&quot;&lt;?php echo esc_attr( $tax-&gt;labels-&gt;add_new_item ); ?&gt;&quot; tabindex=&quot;3&quot; /&gt;
</span><del>-                                        &lt;?php wp_nonce_field( 'add-'.$taxonomy, '_ajax_nonce', false ); ?&gt;
</del><ins>+                                        &lt;?php wp_nonce_field( 'add-'.$taxonomy, '_ajax_nonce-add-'.$taxonomy, false ); ?&gt;
</ins><span class="cx">                                         &lt;span id=&quot;&lt;?php echo $taxonomy; ?&gt;-ajax-response&quot;&gt;&lt;/span&gt;
</span><span class="cx">                                 &lt;/p&gt;
</span><span class="cx">                         &lt;/div&gt;
</span></span></pre></div>
<a id="trunkwpadminincludestemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/template.php (14932 => 14933)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/template.php        2010-05-26 04:36:42 UTC (rev 14932)
+++ trunk/wp-admin/includes/template.php        2010-05-26 04:55:21 UTC (rev 14933)
</span><span class="lines">@@ -2286,7 +2286,7 @@
</span><span class="cx">         &lt;input type=&quot;hidden&quot; name=&quot;position&quot; id=&quot;position&quot; value=&quot;&lt;?php echo $position; ?&gt;&quot; /&gt;
</span><span class="cx">         &lt;input type=&quot;hidden&quot; name=&quot;checkbox&quot; id=&quot;checkbox&quot; value=&quot;&lt;?php echo $checkbox ? 1 : 0; ?&gt;&quot; /&gt;
</span><span class="cx">         &lt;input type=&quot;hidden&quot; name=&quot;mode&quot; id=&quot;mode&quot; value=&quot;&lt;?php echo esc_attr($mode); ?&gt;&quot; /&gt;
</span><del>-        &lt;?php wp_nonce_field( 'replyto-comment', '_ajax_nonce', false ); ?&gt;
</del><ins>+        &lt;?php wp_nonce_field( 'replyto-comment', '_ajax_nonce-replyto-comment', false ); ?&gt;
</ins><span class="cx">         &lt;?php wp_comment_form_unfiltered_html_nonce(); ?&gt;
</span><span class="cx"> &lt;?php if ( $table_row ) : ?&gt;
</span><span class="cx"> &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;
</span><span class="lines">@@ -2462,7 +2462,7 @@
</span><span class="cx"> 
</span><span class="cx"> &lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;submit&quot;&gt;
</span><span class="cx"> &lt;input type=&quot;submit&quot; id=&quot;addmetasub&quot; name=&quot;addmeta&quot; class=&quot;add:the-list:newmeta&quot; tabindex=&quot;9&quot; value=&quot;&lt;?php esc_attr_e( 'Add Custom Field' ) ?&gt;&quot; /&gt;
</span><del>-&lt;?php wp_nonce_field( 'add-meta', '_ajax_nonce', false ); ?&gt;
</del><ins>+&lt;?php wp_nonce_field( 'add-meta', '_ajax_nonce-add-meta', false ); ?&gt;
</ins><span class="cx"> &lt;/td&gt;&lt;/tr&gt;
</span><span class="cx"> &lt;/tbody&gt;
</span><span class="cx"> &lt;/table&gt;
</span></span></pre>
</div>
</div>

</body>
</html>