<!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->name );
</ins><span class="cx">         if ( !current_user_can( $taxonomy->cap->edit_terms ) )
</span><span class="cx">                 die('-1');
</span><span class="cx">         $names = explode(',', $_POST['new'.$taxonomy->name]);
</span><span class="lines">@@ -702,7 +702,7 @@
</span><span class="cx">         $x->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->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">                                         </label>
</span><span class="cx">                                         <?php wp_dropdown_categories( array( 'taxonomy' => $taxonomy, 'hide_empty' => 0, 'name' => 'new'.$taxonomy.'_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => '&mdash; ' . $tax->labels->parent_item . ' &mdash;', 'tab_index' => 3 ) ); ?>
</span><span class="cx">                                         <input type="button" id="<?php echo $taxonomy; ?>-add-submit" class="add:<?php echo $taxonomy ?>checklist:<?php echo $taxonomy ?>-add button category-add-sumbit" value="<?php echo esc_attr( $tax->labels->add_new_item ); ?>" tabindex="3" />
</span><del>-                                        <?php wp_nonce_field( 'add-'.$taxonomy, '_ajax_nonce', false ); ?>
</del><ins>+                                        <?php wp_nonce_field( 'add-'.$taxonomy, '_ajax_nonce-add-'.$taxonomy, false ); ?>
</ins><span class="cx">                                         <span id="<?php echo $taxonomy; ?>-ajax-response"></span>
</span><span class="cx">                                 </p>
</span><span class="cx">                         </div>
</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">         <input type="hidden" name="position" id="position" value="<?php echo $position; ?>" />
</span><span class="cx">         <input type="hidden" name="checkbox" id="checkbox" value="<?php echo $checkbox ? 1 : 0; ?>" />
</span><span class="cx">         <input type="hidden" name="mode" id="mode" value="<?php echo esc_attr($mode); ?>" />
</span><del>-        <?php wp_nonce_field( 'replyto-comment', '_ajax_nonce', false ); ?>
</del><ins>+        <?php wp_nonce_field( 'replyto-comment', '_ajax_nonce-replyto-comment', false ); ?>
</ins><span class="cx">         <?php wp_comment_form_unfiltered_html_nonce(); ?>
</span><span class="cx"> <?php if ( $table_row ) : ?>
</span><span class="cx"> </td></tr></tbody></table>
</span><span class="lines">@@ -2462,7 +2462,7 @@
</span><span class="cx">
</span><span class="cx"> <tr><td colspan="2" class="submit">
</span><span class="cx"> <input type="submit" id="addmetasub" name="addmeta" class="add:the-list:newmeta" tabindex="9" value="<?php esc_attr_e( 'Add Custom Field' ) ?>" />
</span><del>-<?php wp_nonce_field( 'add-meta', '_ajax_nonce', false ); ?>
</del><ins>+<?php wp_nonce_field( 'add-meta', '_ajax_nonce-add-meta', false ); ?>
</ins><span class="cx"> </td></tr>
</span><span class="cx"> </tbody>
</span><span class="cx"> </table>
</span></span></pre>
</div>
</div>
</body>
</html>