Make WordPress Core

Opened 12 years ago

Closed 11 years ago

Last modified 11 years ago

#22619 closed defect (bug) (fixed)

add_rewrite_endpoint generates incorrect attachment rules

Reported by: batmoo's profile batmoo Owned by: duck_'s profile duck_
Milestone: 3.7 Priority: normal
Severity: normal Version:
Component: Rewrite Rules Keywords: has-patch 3.7-early
Focuses: Cc:

Description

add_rewrite_endpoint with EP_ALL or EP_ATTACHMENT results in incorrect endpoint matches. The index set for the endpoint value is 2 which ends up returning the slash as well. The index should actually be 3 since we only care about the inner match.

Example:

add_rewrite_endpoint( 'my-endpoint', EP_ALL )

Results in rules like (dump from $wp_rewrite->generate_rules:

  '.?.+?/([^/]+)/my-endpoint(/(.*))?/?$' =>
  string(35) "index.php?attachment=$1&my-endpoint=$2"
  '.?.+?/attachment/([^/]+)/my-endpoint(/(.*))?/?$' =>
  string(35) "index.php?attachment=$1&my-endpoint=$2"

Visiting a my-endpoint URL for an attachment like /2012/01/01/post-name/attachment/my-endpoint/foo/ will return the value of get_query_var( 'my-endpoint' ) as /foo instead of foo.

Attachments (1)

22619.diff (689 bytes) - added by duck_ 11 years ago.

Download all attachments as: .zip

Change History (8)

#1 @toscho
12 years ago

  • Cc info@… added

#2 @knutsp
12 years ago

  • Cc knut@… added

#3 @LucasMS
11 years ago

  • Cc LucasMS added

@duck_
11 years ago

#4 @duck_
11 years ago

  • Keywords has-patch added
  • Milestone changed from Awaiting Review to Future Release

#5 @SergeyBiryukov
11 years ago

  • Keywords 3.7-early added

#6 @duck_
11 years ago

  • Owner set to duck_
  • Resolution set to fixed
  • Status changed from new to closed

In 24809:

Drop leading / by retrieving the inner subpattern when matching attachment endpoints.

Fixes #22619

#7 @duck_
11 years ago

  • Milestone changed from Future Release to 3.7
Note: See TracTickets for help on using tickets.