[wp-trac] [WordPress Trac] #62568: MAX_LENGTH = 64 in /wp-includes/Requests/src/IdnaEncoder.php is too restrictive for modern URL use cases.

WordPress Trac noreply at wordpress.org
Mon Nov 25 16:40:34 UTC 2024


#62568: MAX_LENGTH = 64 in /wp-includes/Requests/src/IdnaEncoder.php is too
restrictive for modern URL use cases.
-------------------------+-----------------------------
 Reporter:  knufflpuffl  |      Owner:  (none)
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Charset      |    Version:  trunk
 Severity:  normal       |   Keywords:
  Focuses:               |
-------------------------+-----------------------------
 The constant MAX_LENGTH in /wp-includes/Requests/src/IdnaEncoder.php is
 currently set to 64 characters, which imposes a significant restriction on
 URL handling. This limitation can be easily exceeded in real-world
 scenarios, especially when using subdomains or long permalinks in
 WordPress.

 **Problem Details:
 **
 File: /wp-includes/Requests/src/IdnaEncoder.php
 Line of code: const MAX_LENGTH = 64;

 **Issue:**
 Many URLs, especially those involving subdomains or dynamically generated
 paths, can exceed 64 characters.

 For example:
 Multi-site setups often use subdomains that add significant length to
 URLs.
 Permalinks with long slugs (e.g., descriptive titles or nested categories)
 can quickly exceed this limit.

 API endpoints and external services often rely on longer, structured URLs.

 **Why This Matters:**
 Modern browsers, web servers, and standards allow for significantly longer
 URLs.
 64 characters is insufficient and may lead to truncation or errors when
 handling valid URLs.
 WordPress is known for its flexibility, but this low limit could restrict
 users unnecessarily.

 **Proposed Solution:**
 Increase the MAX_LENGTH constant to a more realistic value, such as 255
 characters, which aligns with database and standard practices.
 Alternatively, make the MAX_LENGTH configurable, allowing developers to
 adjust the limit based on their specific use case.

 **Steps to Reproduce:**
 Set up a WordPress site with a subdomain exceeding 64 characters in total
 length (e.g., https://a-very-long-subdomain-name.example.com).
 Attempt to use features that encode URLs via the IdnaEncoder class.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/62568>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list