Make WordPress Core

Ticket #16230: 16230-category-slug-length-fix-v2.diff

File 16230-category-slug-length-fix-v2.diff, 855 bytes (added by sachinrajcp123, 3 months ago)
  • wp-includes/taxonomy.php

    diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php
    index 7c9a1d7a1f..c34e0e8b4d 100644
    a b function sanitize_term_field( $field, $value, $term_id, $taxonomy, $context ) { 
    17101710
    17111711        if ( 'slug' === $field ) {
    17121712                $value = sanitize_title( $value );
     1713
     1714                /*
     1715                 * Enforce maximum slug length AFTER decoding.
     1716                 * This prevents URL-encoded or multibyte strings
     1717                 * from exceeding the 200 character limit and
     1718                 * breaking admin pagination queries.
     1719                 */
     1720                $decoded_slug = rawurldecode( $value );
     1721
     1722                if ( strlen( $decoded_slug ) > 200 ) {
     1723                        $decoded_slug = substr( $decoded_slug, 0, 200 );
     1724
     1725                        // Re-sanitize after truncation to ensure valid slug.
     1726                        $value = sanitize_title( $decoded_slug );
     1727                }
    17131728        }
    17141729
    17151730        if ( 'db' === $context ) {