<!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>[13137] trunk:
  Use an expanded special character set when generating auth keys and salts via wp_generate_password
 ().</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/13137">13137</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2010-02-14 04:06:30 +0000 (Sun, 14 Feb 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Use an expanded special character set when generating auth keys and salts via wp_generate_password(). Props sivel, see <a href="http://trac.wordpress.org/ticket/12159">#12159</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludesschemaphp">trunk/wp-admin/includes/schema.php</a></li>
<li><a href="#trunkwpadminsetupconfigphp">trunk/wp-admin/setup-config.php</a></li>
<li><a href="#trunkwpincludespluggablephp">trunk/wp-includes/pluggable.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminincludesschemaphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/schema.php (13136 => 13137)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/schema.php        2010-02-14 03:28:34 UTC (rev 13136)
+++ trunk/wp-admin/includes/schema.php        2010-02-14 04:06:30 UTC (rev 13137)
</span><span class="lines">@@ -265,7 +265,7 @@
</span><span class="cx">         'upload_path' =&gt; '',
</span><span class="cx"> 
</span><span class="cx">         // 2.0.3
</span><del>-        'secret' =&gt; wp_generate_password(64),
</del><ins>+        'secret' =&gt; wp_generate_password( 64, true, true ),
</ins><span class="cx"> 
</span><span class="cx">         // 2.1
</span><span class="cx">         'blog_public' =&gt; '1',
</span></span></pre></div>
<a id="trunkwpadminsetupconfigphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/setup-config.php (13136 => 13137)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/setup-config.php        2010-02-14 03:28:34 UTC (rev 13136)
+++ trunk/wp-admin/setup-config.php        2010-02-14 04:06:30 UTC (rev 13137)
</span><span class="lines">@@ -189,7 +189,7 @@
</span><span class="cx">                 $secret_keys = array();
</span><span class="cx">                 require_once( ABSPATH . WPINC . '/pluggable.php' );
</span><span class="cx">                 for ( $i = 0; $i &lt; 8; $i++ )
</span><del>-                        $secret_keys[] = wp_generate_password( 64 );
</del><ins>+                        $secret_keys[] = wp_generate_password( 64, true, true );
</ins><span class="cx">         } else {
</span><span class="cx">                 $secret_keys = explode( &quot;\n&quot;, wp_remote_retrieve_body( $secret_keys ) );
</span><span class="cx">                 foreach ( $secret_keys as $k =&gt; $v )
</span></span></pre></div>
<a id="trunkwpincludespluggablephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/pluggable.php (13136 => 13137)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/pluggable.php        2010-02-14 03:28:34 UTC (rev 13136)
+++ trunk/wp-includes/pluggable.php        2010-02-14 04:06:30 UTC (rev 13137)
</span><span class="lines">@@ -1308,7 +1308,7 @@
</span><span class="cx">                 } else {
</span><span class="cx">                         $salt = get_option('auth_salt');
</span><span class="cx">                         if ( empty($salt) ) {
</span><del>-                                $salt = wp_generate_password(64);
</del><ins>+                                $salt = wp_generate_password( 64, true, true );
</ins><span class="cx">                                 update_option('auth_salt', $salt);
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="lines">@@ -1321,7 +1321,7 @@
</span><span class="cx">                 } else {
</span><span class="cx">                         $salt = get_option('secure_auth_salt');
</span><span class="cx">                         if ( empty($salt) ) {
</span><del>-                                $salt = wp_generate_password(64);
</del><ins>+                                $salt = wp_generate_password( 64, true, true );
</ins><span class="cx">                                 update_option('secure_auth_salt', $salt);
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="lines">@@ -1334,7 +1334,7 @@
</span><span class="cx">                 } else {
</span><span class="cx">                         $salt = get_option('logged_in_salt');
</span><span class="cx">                         if ( empty($salt) ) {
</span><del>-                                $salt = wp_generate_password(64);
</del><ins>+                                $salt = wp_generate_password( 64, true, true );
</ins><span class="cx">                                 update_option('logged_in_salt', $salt);
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="lines">@@ -1347,7 +1347,7 @@
</span><span class="cx">                 } else {
</span><span class="cx">                         $salt = get_option('nonce_salt');
</span><span class="cx">                         if ( empty($salt) ) {
</span><del>-                                $salt = wp_generate_password(64);
</del><ins>+                                $salt = wp_generate_password( 64, true, true );
</ins><span class="cx">                                 update_option('nonce_salt', $salt);
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="lines">@@ -1461,13 +1461,18 @@
</span><span class="cx">  * @since 2.5
</span><span class="cx">  *
</span><span class="cx">  * @param int $length The length of password to generate
</span><del>- * @param bool $special_chars Whether to include standard special characters
</del><ins>+ * @param bool $special_chars Whether to include standard special characters. Default true.
+ * @param bool $extra_special_chars Whether to include more special characters. Used
+ *   when generating secret keys and salts. Default false.
</ins><span class="cx">  * @return string The random password
</span><span class="cx">  **/
</span><del>-function wp_generate_password($length = 12, $special_chars = true) {
</del><ins>+function wp_generate_password( $length = 12, $special_chars = true, $extra_special_chars = false ) {
</ins><span class="cx">         $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
</span><del>-        if ( $special_chars )
</del><ins>+        if ( $special_chars ) {
</ins><span class="cx">                 $chars .= '!@#$%^&amp;*()';
</span><ins>+                if ( $extra_special_chars )
+                        $chars .= '-_ []{}&lt;&gt;~`+=,.;:/?|';
+        }
</ins><span class="cx"> 
</span><span class="cx">         $password = '';
</span><span class="cx">         for ( $i = 0; $i &lt; $length; $i++ ) {
</span></span></pre>
</div>
</div>

</body>
</html>