Make WordPress Core

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#38976 closed defect (bug) (wontfix)

REST API: Allow multiple leading slashes at the beginning of the endpoint path

Reported by: jnylen0's profile jnylen0 Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.7
Component: REST API Keywords: has-patch close
Focuses: Cc:


Follow-up to #38873. The official API console is currently broken on all of my sites due to a duplicated slash in between the REST prefix and the namespace (wp-json//wp/v2/posts):

Since this is an easy mistake to make, and it's broken in a released plugin, let's fix it.

Attachments (1)

38976.diff (490 bytes) - added by jnylen0 7 years ago.

Download all attachments as: .zip

Change History (8)

7 years ago

#1 @rachelbaker
7 years ago

@jnylen0 What is the impact of this change on sites with non-pretty permalinks or index links?

#2 @jnylen0
7 years ago

Under other permalink structures, it looks like this change will still fix things without breaking other things.

The console sends /?rest_route=//wp/v2/posts which fails unless this change is made.

Permalink structure: /index.php/%year%/%monthnum%/%day%/%postname%/

The console sends /index.php/wp-json//wp/v2/posts which works fine either way.

The rest_route query var is correctly /wp/v2/posts before this change; I'm not sure if this is because of my server or WP internals.

#3 @joehoyle
7 years ago

I might be misunderstanding this, is it that we should support // in URLs, or is it that we should never make URLs with // in them? If it's the former, I think that's a terrible idea, if it's the latter, I think it's a great idea :D

This ticket was mentioned in Slack in #core-restapi by joehoyle. View the logs.

7 years ago

#5 @jnylen0
7 years ago

There is at least 1 plugin out in the wild that does this incorrectly... and it's by "WP REST API Team" and we officially promote it.

Presumably the console worked at one point, so whenever it stopped working was a BC break.

Also, if the people most familiar with the API made a mistake here, how can we expect other WP devs not to make the same mistake?

#6 @rachelbaker
7 years ago

  • Keywords close added

As noted in the #core-restapi slack channel they console plugin was a 1 week hack project to port over the console for the REST API. The console plugin should be fixed (and will be by @joehoyle).
I do not think we should support // paths in core and recommend closing this ticket.

#7 @jnylen0
7 years ago

  • Milestone 4.7 deleted
  • Resolution set to wontfix
  • Status changed from new to closed

It looks like this is already fixed in the plugin's repo:

@rmccue can you deploy a new version of the console plugin from master? Edit: done, thanks!

Last edited 7 years ago by jnylen0 (previous) (diff)
Note: See TracTickets for help on using tickets.