Make WordPress Core

Opened 10 years ago

Closed 9 years ago

#34725 closed defect (bug) (duplicate)

Require registered endpoints arguments to have a validate or sanitize callback

Reported by: danielbachhuber's profile danielbachhuber Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: REST API Keywords: needs-patch
Focuses: Cc:

Description (last modified by danielbachhuber)

From https://github.com/WP-API/WP-API/pull/1281#issuecomment-111337989:

We're going to tone this one down a bit. Instead of requiring all arguments to be registered, we're going to require all registered arguments to have either a validation callback or a sanitisation callback (or both!). This stops people from accidentally misspelling validate_callback/sanitize_callback, but won't stop them from accessing other unregistered arguments.

Currently, developers can register arguments without any default form of validation or sanitization.

Original issue on Github: https://github.com/WP-API/WP-API/issues/1223

Change History (7)

#1 @danielbachhuber
10 years ago

  • Summary changed from Require registered endppoints arguments to have a validate or sanitize callback to Require registered endpoints arguments to have a validate or sanitize callback

This ticket was mentioned in Slack in #core by danielbachhuber. View the logs.


10 years ago

#3 @danielbachhuber
10 years ago

From the Slack conversation, some of the options present to us:

  • Default to sanitize_text_field() when no validation or sanitization callback is specified, but this can't guarantee security.
  • Silently discard the argument if validation or sanitization hasn’t been specified.
  • Error any misspelled callbacks, but don't require one. register_setting() has these callbacks as optional.

#4 @danielbachhuber
10 years ago

  • Description modified (diff)

This ticket was mentioned in Slack in #core by danielbachhuber. View the logs.


10 years ago

#6 @danielbachhuber
10 years ago

  • Milestone changed from 4.4 to Future Release

Bumping this out of 4.4

Personally, I still think we should discard any arguments that haven’t been explicitly registered. But, it seems like the consensus is the opposite: let the arguments through, even if they haven't been registered, or don't have validation / sanitization callbacks.

Eventually, we could trigger an error if the validation or sanitization callback is invalid. But, that doesn't need to happen for 4.4

#7 @rmccue
9 years ago

  • Milestone Future Release deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #35000.

Note: See TracTickets for help on using tickets.