WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#30869 closed defect (bug) (duplicate)

Output of esc_url doesn't allow brackets

Reported by: rabmalin Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.0
Component: Formatting Keywords:
Focuses: Cc:
PR Number:

Description

$args = array(
 'autofocus[control]' => 'blogname',
);
$url = add_query_arg( $args, admin_url('customize.php' ));
echo esc_url($url);

Current output:
http://staging.dev/wp-admin/customize.php?autofocuscontrol=blogname

Expected output:
http://staging.dev/wp-admin/customize.php?autofocus[control]=blogname

I was trying to generate auto focus URL for customize page. I generally use esc_url to escape any URL in WordPress. But I could not produce expected URL when URL is escaped with the function. Is this expected feature of the function? Can someone please help make me clear about this?
Thanks.

Attachments (1)

30869.diff (1.3 KB) - added by valendesigns 5 years ago.

Download all attachments as: .zip

Change History (3)

@valendesigns
5 years ago

#1 @valendesigns
5 years ago

  • Component changed from General to Formatting
  • Keywords has-patch dev-feedback added
  • Summary changed from Output of `esc_url` to Output of esc_url doesn't allow brackets
  • Version changed from 4.1 to 3.0

Here is a patch with unit tests to fix the issue; all other formatting unit tests continue passing. It appears the regex pattern was introduced in #12309 and hasn't changed since.

#2 @dd32
5 years ago

  • Keywords has-patch dev-feedback removed
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #16859.

Note: See TracTickets for help on using tickets.