WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#41909 closed defect (bug) (invalid)

Break statement missing in switch case in function.php file in wp-includes

Reported by: lalitpendhare Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: General Keywords:
Focuses: Cc:

Description

Break statement missing in switch case in function.php file in wp-includes on line number 388 to 399

switch ( $token ) {
		case 's' :
			if ( $strict ) {
				if ( '"' !== substr( $data, -2, 1 ) ) {
					return false;
				}
			} elseif ( false === strpos( $data, '"' ) ) {
				return false;
			}
			break;
			// or else fall through
		case 'a' : break;
		case 'O' :
			return (bool) preg_match( "/^{$token}:[0-9]+:/s", $data );
			break;
		case 'b' : break;
		case 'i' : break;
		case 'd' :
			$end = $strict ? '$' : '';
			return (bool) preg_match( "/^{$token}:[0-9.E-]+;$end/", $data );
			break;

Attachments (1)

41909.patch (639 bytes) - added by lalitpendhare 3 years ago.

Download all attachments as: .zip

Change History (4)

@lalitpendhare
3 years ago

#1 @ocean90
3 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Hello @lalitpendhare, thanks for your patch but the switch statement is correct as it is. There's no need for the break keyword after a return.

#2 @lalitpendhare
3 years ago

Hello @ocean90, thanks for your quick response and suggestion about break statement.

#3 @SergeyBiryukov
3 years ago

There's also no need for break after the "empty" cases here (case 'a', case 'b', case 'i'), as it will prevent them from falling through to the next case, which is what the current code is supposed to do.

Note: See TracTickets for help on using tickets.