WordPress.org

Make WordPress Core

Ticket #16839: 16839.diff

File 16839.diff, 640 bytes (added by garyc40, 4 years ago)

sanitize category_base before saving to the db

  • wp-admin/options-permalink.php

    diff --git wp-admin/options-permalink.php wp-admin/options-permalink.php
    index e5f9a75..f550fe4 100644
    if ( isset($_POST['permalink_structure']) || isset($_POST['category_base']) ) { 
    8585        } 
    8686 
    8787        if ( isset( $_POST['category_base'] ) ) { 
    88                 $category_base = $_POST['category_base']; 
     88                $category_base = sanitize_title_with_dashes( $_POST['category_base'] ); 
    8989                if ( ! empty( $category_base ) ) 
    9090                        $category_base = $blog_prefix . preg_replace('#/+#', '/', '/' . str_replace( '#', '', $category_base ) ); 
    9191                $wp_rewrite->set_category_base( $category_base );