[wp-trac] [WordPress Trac] #53553: strpos(): Empty needle in /wp-includes/l10n.php on line 1047

WordPress Trac noreply at wordpress.org
Tue Jun 29 20:11:42 UTC 2021


#53553: strpos(): Empty needle in /wp-includes/l10n.php on line 1047
--------------------------+-----------------------------
 Reporter:  gwviger       |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  5.7.2
 Severity:  normal        |   Keywords:  has-patch
  Focuses:                |
--------------------------+-----------------------------
 There was a previous ticket for a similar problem
 [https://core.trac.wordpress.org/ticket/46387#ticket] that was resolved
 but a similar issue has appeared on line 1047 of /wp-includes/l10n.php.
 Existed in 5.6.x. Still exists in 5.7.2.

 Seems problem shows up when wp-config.php includes:
 {{{#!php
 <?php
 define('WP_CONTENT_URL', $_SERVER[‘HTTP_HOST’])
 }}}


 Issue: $content_url is returned as empty string "". strpos() creates
 notice on empty value  as needle.

 Current Code:
 {{{#!php
 <?php
 if (
                 ( ! isset( $content_url['path'] )  || strpos(
 $src_url['path'], $content_url['path'] ) === 0 ) &&
                 ( ! isset( $src_url['host'] ) || ! isset(
 $content_url['host'] ) || $src_url['host'] === $content_url['host'] )
         )
 }}}


 Fix is to add
 {{{#!php
 <?php
 ||  empty($content_url['path'])
 }}}




 Fixed code:


 {{{#!php
 <?php
 if (
                 ( ! isset( $content_url['path'] ) ||
 empty($content_url['path']) || strpos( $src_url['path'],
 $content_url['path'] ) === 0 ) &&
                 ( ! isset( $src_url['host'] ) || ! isset(
 $content_url['host'] ) || $src_url['host'] === $content_url['host'] )
         )

 }}}

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


More information about the wp-trac mailing list