<!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" />
<title>[21755] trunk/wp-admin: Always URL-encode a stylesheet directory value before using it in a URL.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { 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 #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#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>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/21755">21755</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2012-09-04 22:35:12 +0000 (Tue, 04 Sep 2012)</dd>
</dl>

<h3>Log Message</h3>
<pre>Always URL-encode a stylesheet directory value before using it in a URL. These situations are saved by wp_nonce_url(), but we should not depend on that. see <a href="http://core.trac.wordpress.org/ticket/21749">#21749</a>, for trunk only.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludesclasswpmsthemeslisttablephp">trunk/wp-admin/includes/class-wp-ms-themes-list-table.php</a></li>
<li><a href="#trunkwpadminincludesclasswpthemeslisttablephp">trunk/wp-admin/includes/class-wp-themes-list-table.php</a></li>
<li><a href="#trunkwpadminincludesclasswpupgraderphp">trunk/wp-admin/includes/class-wp-upgrader.php</a></li>
<li><a href="#trunkwpadminincludesthemephp">trunk/wp-admin/includes/theme.php</a></li>
<li><a href="#trunkwpadminthemeeditorphp">trunk/wp-admin/theme-editor.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminincludesclasswpmsthemeslisttablephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/class-wp-ms-themes-list-table.php (21754 => 21755)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/class-wp-ms-themes-list-table.php        2012-09-04 22:27:52 UTC (rev 21754)
+++ trunk/wp-admin/includes/class-wp-ms-themes-list-table.php        2012-09-04 22:35:12 UTC (rev 21755)
</span><span class="lines">@@ -277,27 +277,28 @@
</span><span class="cx">                         'delete' =&gt; ''
</span><span class="cx">                 );
</span><span class="cx"> 
</span><del>-                $theme_key = $theme-&gt;get_stylesheet();
</del><ins>+                $stylesheet = $theme-&gt;get_stylesheet();
+                $theme_key = urlencode( $stylesheet );
</ins><span class="cx"> 
</span><span class="cx">                 if ( ! $allowed ) {
</span><span class="cx">                         if ( ! $theme-&gt;errors() )
</span><del>-                                $actions['enable'] = '&lt;a href=&quot;' . esc_url( wp_nonce_url($url . 'action=enable&amp;amp;theme=' . $theme_key . '&amp;amp;paged=' . $page . '&amp;amp;s=' . $s, 'enable-theme_' . $theme_key) ) . '&quot; title=&quot;' . esc_attr__('Enable this theme') . '&quot; class=&quot;edit&quot;&gt;' . ( $this-&gt;is_site_themes ? __( 'Enable' ) : __( 'Network Enable' ) ) . '&lt;/a&gt;';
</del><ins>+                                $actions['enable'] = '&lt;a href=&quot;' . esc_url( wp_nonce_url($url . 'action=enable&amp;amp;theme=' . $theme_key . '&amp;amp;paged=' . $page . '&amp;amp;s=' . $s, 'enable-theme_' . $stylesheet ) ) . '&quot; title=&quot;' . esc_attr__('Enable this theme') . '&quot; class=&quot;edit&quot;&gt;' . ( $this-&gt;is_site_themes ? __( 'Enable' ) : __( 'Network Enable' ) ) . '&lt;/a&gt;';
</ins><span class="cx">                 } else {
</span><del>-                        $actions['disable'] = '&lt;a href=&quot;' . esc_url( wp_nonce_url($url . 'action=disable&amp;amp;theme=' . $theme_key . '&amp;amp;paged=' . $page . '&amp;amp;s=' . $s, 'disable-theme_' . $theme_key) ) . '&quot; title=&quot;' . esc_attr__('Disable this theme') . '&quot;&gt;' . ( $this-&gt;is_site_themes ? __( 'Disable' ) : __( 'Network Disable' ) ) . '&lt;/a&gt;';
</del><ins>+                        $actions['disable'] = '&lt;a href=&quot;' . esc_url( wp_nonce_url($url . 'action=disable&amp;amp;theme=' . $theme_key . '&amp;amp;paged=' . $page . '&amp;amp;s=' . $s, 'disable-theme_' . $stylesheet ) ) . '&quot; title=&quot;' . esc_attr__('Disable this theme') . '&quot;&gt;' . ( $this-&gt;is_site_themes ? __( 'Disable' ) : __( 'Network Disable' ) ) . '&lt;/a&gt;';
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 if ( current_user_can('edit_themes') )
</span><del>-                        $actions['edit'] = '&lt;a href=&quot;' . esc_url('theme-editor.php?theme=' . urlencode( $theme_key ) ) . '&quot; title=&quot;' . esc_attr__('Open this theme in the Theme Editor') . '&quot; class=&quot;edit&quot;&gt;' . __('Edit') . '&lt;/a&gt;';
</del><ins>+                        $actions['edit'] = '&lt;a href=&quot;' . esc_url('theme-editor.php?theme=' . $theme_key ) . '&quot; title=&quot;' . esc_attr__('Open this theme in the Theme Editor') . '&quot; class=&quot;edit&quot;&gt;' . __('Edit') . '&lt;/a&gt;';
</ins><span class="cx"> 
</span><del>-                if ( ! $allowed &amp;&amp; current_user_can( 'delete_themes' ) &amp;&amp; ! $this-&gt;is_site_themes &amp;&amp; $theme_key != get_option( 'stylesheet' ) &amp;&amp; $theme_key != get_option( 'template' ) )
</del><ins>+                if ( ! $allowed &amp;&amp; current_user_can( 'delete_themes' ) &amp;&amp; ! $this-&gt;is_site_themes &amp;&amp; $stylesheet != get_option( 'stylesheet' ) &amp;&amp; $stylesheet != get_option( 'template' ) )
</ins><span class="cx">                         $actions['delete'] = '&lt;a href=&quot;' . esc_url( wp_nonce_url( 'themes.php?action=delete-selected&amp;amp;checked[]=' . $theme_key . '&amp;amp;theme_status=' . $context . '&amp;amp;paged=' . $page . '&amp;amp;s=' . $s, 'bulk-themes' ) ) . '&quot; title=&quot;' . esc_attr__( 'Delete this theme' ) . '&quot; class=&quot;delete&quot;&gt;' . __( 'Delete' ) . '&lt;/a&gt;';
</span><span class="cx"> 
</span><del>-                $actions = apply_filters( 'theme_action_links', array_filter( $actions ), $theme_key, $theme, $context );
-                $actions = apply_filters( &quot;theme_action_links_$theme_key&quot;, $actions, $theme_key, $theme, $context );
</del><ins>+                $actions = apply_filters( 'theme_action_links', array_filter( $actions ), $stylesheet, $theme, $context );
+                $actions = apply_filters( &quot;theme_action_links_$stylesheet&quot;, $actions, $stylesheet, $theme, $context );
</ins><span class="cx"> 
</span><span class="cx">                 $class = ! $allowed ? 'inactive' : 'active';
</span><span class="cx">                 $checkbox_id = &quot;checkbox_&quot; . md5( $theme-&gt;get('Name') );
</span><del>-                $checkbox = &quot;&lt;input type='checkbox' name='checked[]' value='&quot; . esc_attr( $theme_key ) . &quot;' id='&quot; . $checkbox_id . &quot;' /&gt;&lt;label class='screen-reader-text' for='&quot; . $checkbox_id . &quot;' &gt;&quot; . __('Select') . &quot; &quot; . $theme-&gt;display('Name') . &quot;&lt;/label&gt;&quot;;
</del><ins>+                $checkbox = &quot;&lt;input type='checkbox' name='checked[]' value='&quot; . esc_attr( $stylesheet ) . &quot;' id='&quot; . $checkbox_id . &quot;' /&gt;&lt;label class='screen-reader-text' for='&quot; . $checkbox_id . &quot;' &gt;&quot; . __('Select') . &quot; &quot; . $theme-&gt;display('Name') . &quot;&lt;/label&gt;&quot;;
</ins><span class="cx"> 
</span><span class="cx">                 $id = sanitize_html_class( $theme-&gt;get_stylesheet() );
</span><span class="cx"> 
</span><span class="lines">@@ -341,7 +342,7 @@
</span><span class="cx">                                         if ( $theme-&gt;get('ThemeURI') )
</span><span class="cx">                                                 $theme_meta[] = '&lt;a href=&quot;' . $theme-&gt;display('ThemeURI') . '&quot; title=&quot;' . esc_attr__( 'Visit theme homepage' ) . '&quot;&gt;' . __( 'Visit Theme Site' ) . '&lt;/a&gt;';
</span><span class="cx"> 
</span><del>-                                        $theme_meta = apply_filters( 'theme_row_meta', $theme_meta, $theme_key, $theme, $status );
</del><ins>+                                        $theme_meta = apply_filters( 'theme_row_meta', $theme_meta, $stylesheet, $theme, $status );
</ins><span class="cx">                                         echo implode( ' | ', $theme_meta );
</span><span class="cx"> 
</span><span class="cx">                                         echo &quot;&lt;/div&gt;&lt;/td&gt;&quot;;
</span><span class="lines">@@ -349,7 +350,7 @@
</span><span class="cx"> 
</span><span class="cx">                                 default:
</span><span class="cx">                                         echo &quot;&lt;td class='$column_name column-$column_name'$style&gt;&quot;;
</span><del>-                                        do_action( 'manage_themes_custom_column', $column_name, $theme_key, $theme );
</del><ins>+                                        do_action( 'manage_themes_custom_column', $column_name, $stylesheet, $theme );
</ins><span class="cx">                                         echo &quot;&lt;/td&gt;&quot;;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="lines">@@ -357,8 +358,8 @@
</span><span class="cx">                 echo &quot;&lt;/tr&gt;&quot;;
</span><span class="cx"> 
</span><span class="cx">                 if ( $this-&gt;is_site_themes )
</span><del>-                        remove_action( &quot;after_theme_row_$theme_key&quot;, 'wp_theme_update_row' );
-                do_action( 'after_theme_row', $theme_key, $theme, $status );
-                do_action( &quot;after_theme_row_$theme_key&quot;, $theme_key, $theme, $status );
</del><ins>+                        remove_action( &quot;after_theme_row_$stylesheet&quot;, 'wp_theme_update_row' );
+                do_action( 'after_theme_row', $stylesheet, $theme, $status );
+                do_action( &quot;after_theme_row_$stylesheet&quot;, $stylesheet, $theme, $status );
</ins><span class="cx">         }
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkwpadminincludesclasswpthemeslisttablephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/class-wp-themes-list-table.php (21754 => 21755)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/class-wp-themes-list-table.php        2012-09-04 22:27:52 UTC (rev 21754)
+++ trunk/wp-admin/includes/class-wp-themes-list-table.php        2012-09-04 22:35:12 UTC (rev 21755)
</span><span class="lines">@@ -143,7 +143,7 @@
</span><span class="cx">                                         . __( 'Live Preview' ) . '&lt;/a&gt;';
</span><span class="cx"> 
</span><span class="cx">                         if ( ! is_multisite() &amp;&amp; current_user_can( 'delete_themes' ) )
</span><del>-                                $actions['delete'] = '&lt;a class=&quot;submitdelete deletion&quot; href=&quot;' . wp_nonce_url( &quot;themes.php?action=delete&amp;amp;stylesheet=$stylesheet&quot;, 'delete-theme_' . $stylesheet )
</del><ins>+                                $actions['delete'] = '&lt;a class=&quot;submitdelete deletion&quot; href=&quot;' . wp_nonce_url( 'themes.php?action=delete&amp;amp;stylesheet=' . urlencode( $stylesheet ), 'delete-theme_' . $stylesheet )
</ins><span class="cx">                                         . '&quot; onclick=&quot;' . &quot;return confirm( '&quot; . esc_js( sprintf( __( &quot;You are about to delete this theme '%s'\n  'Cancel' to stop, 'OK' to delete.&quot; ), $title ) )
</span><span class="cx">                                         . &quot;' );&quot; . '&quot;&gt;' . __( 'Delete' ) . '&lt;/a&gt;';
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkwpadminincludesclasswpupgraderphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/class-wp-upgrader.php (21754 => 21755)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/class-wp-upgrader.php        2012-09-04 22:27:52 UTC (rev 21754)
+++ trunk/wp-admin/includes/class-wp-upgrader.php        2012-09-04 22:35:12 UTC (rev 21755)
</span><span class="lines">@@ -1502,7 +1502,7 @@
</span><span class="cx">                         'preview'    =&gt; 1,
</span><span class="cx">                         'template'   =&gt; urlencode( $template ),
</span><span class="cx">                         'stylesheet' =&gt; urlencode( $stylesheet ),
</span><del>-                ), trailingslashit( get_home_url() ) );
</del><ins>+                ), trailingslashit( home_url() ) );
</ins><span class="cx"> 
</span><span class="cx">                 $activate_link = add_query_arg( array(
</span><span class="cx">                         'action'     =&gt; 'activate',
</span><span class="lines">@@ -1517,7 +1517,7 @@
</span><span class="cx">                 $install_actions['activate'] = '&lt;a href=&quot;' . esc_url( $activate_link ) . '&quot; class=&quot;activatelink&quot; title=&quot;' . esc_attr( sprintf( __('Activate &amp;#8220;%s&amp;#8221;'), $name ) ) . '&quot;&gt;' . __('Activate') . '&lt;/a&gt;';
</span><span class="cx"> 
</span><span class="cx">                 if ( is_network_admin() &amp;&amp; current_user_can( 'manage_network_themes' ) )
</span><del>-                        $install_actions['network_enable'] = '&lt;a href=&quot;' . esc_url( wp_nonce_url( 'themes.php?action=enable&amp;amp;theme=' . $stylesheet, 'enable-theme_' . $stylesheet ) ) . '&quot; title=&quot;' . esc_attr__( 'Enable this theme for all sites in this network' ) . '&quot; target=&quot;_parent&quot;&gt;' . __( 'Network Enable' ) . '&lt;/a&gt;';
</del><ins>+                        $install_actions['network_enable'] = '&lt;a href=&quot;' . esc_url( wp_nonce_url( 'themes.php?action=enable&amp;amp;theme=' . urlencode( $stylesheet ), 'enable-theme_' . $stylesheet ) ) . '&quot; title=&quot;' . esc_attr__( 'Enable this theme for all sites in this network' ) . '&quot; target=&quot;_parent&quot;&gt;' . __( 'Network Enable' ) . '&lt;/a&gt;';
</ins><span class="cx"> 
</span><span class="cx">                 if ( $this-&gt;type == 'web' )
</span><span class="cx">                         $install_actions['themes_page'] = '&lt;a href=&quot;' . self_admin_url('theme-install.php') . '&quot; title=&quot;' . esc_attr__('Return to Theme Installer') . '&quot; target=&quot;_parent&quot;&gt;' . __('Return to Theme Installer') . '&lt;/a&gt;';
</span><span class="lines">@@ -1566,7 +1566,7 @@
</span><span class="cx">                                 'preview'    =&gt; 1,
</span><span class="cx">                                 'template'   =&gt; urlencode( $template ),
</span><span class="cx">                                 'stylesheet' =&gt; urlencode( $stylesheet ),
</span><del>-                        ), trailingslashit( get_home_url() ) );
</del><ins>+                        ), trailingslashit( home_url() ) );
</ins><span class="cx"> 
</span><span class="cx">                         $activate_link = add_query_arg( array(
</span><span class="cx">                                 'action'     =&gt; 'activate',
</span></span></pre></div>
<a id="trunkwpadminincludesthemephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/theme.php (21754 => 21755)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/theme.php        2012-09-04 22:27:52 UTC (rev 21754)
+++ trunk/wp-admin/includes/theme.php        2012-09-04 22:35:12 UTC (rev 21755)
</span><span class="lines">@@ -23,7 +23,7 @@
</span><span class="cx"> 
</span><span class="cx">         ob_start();
</span><span class="cx">         if ( empty( $redirect ) )
</span><del>-                $redirect = wp_nonce_url('themes.php?action=delete&amp;stylesheet=' . $stylesheet, 'delete-theme_' . $stylesheet);
</del><ins>+                $redirect = wp_nonce_url('themes.php?action=delete&amp;stylesheet=' . urlencode( $stylesheet ), 'delete-theme_' . $stylesheet);
</ins><span class="cx">         if ( false === ($credentials = request_filesystem_credentials($redirect)) ) {
</span><span class="cx">                 $data = ob_get_contents();
</span><span class="cx">                 ob_end_clean();
</span></span></pre></div>
<a id="trunkwpadminthemeeditorphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/theme-editor.php (21754 => 21755)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/theme-editor.php        2012-09-04 22:27:52 UTC (rev 21754)
+++ trunk/wp-admin/theme-editor.php        2012-09-04 22:35:12 UTC (rev 21755)
</span><span class="lines">@@ -46,7 +46,7 @@
</span><span class="cx"> wp_reset_vars( array( 'action', 'error', 'file', 'theme' ) );
</span><span class="cx"> 
</span><span class="cx"> if ( $theme )
</span><del>-        $stylesheet = urldecode( $theme );
</del><ins>+        $stylesheet = $theme;
</ins><span class="cx"> else
</span><span class="cx">         $stylesheet = get_stylesheet();
</span><span class="cx"> 
</span><span class="lines">@@ -68,7 +68,7 @@
</span><span class="cx">         $relative_file = 'style.css';
</span><span class="cx">         $file = $allowed_files['style.css'];
</span><span class="cx"> } else {
</span><del>-        $relative_file = urldecode( stripslashes( $file ) );
</del><ins>+        $relative_file = stripslashes( $file );
</ins><span class="cx">         $file = $theme-&gt;get_stylesheet_directory() . '/' . $relative_file;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>