Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#34274 closed defect (bug) (fixed)

_oembed_create_xml() uses SimpleXML, which can be disabled

Reported by: johnbillion's profile johnbillion Owned by: wonderboymusic's profile wonderboymusic
Milestone: 4.4 Priority: high
Severity: normal Version: 4.4
Component: Embeds Keywords: has-patch commit
Focuses: Cc:

Description

_oembed_create_xml() uses the SimpleXMLElement class without first detecting whether it's available. Unfortunately, the simplexml extension can be disabled.

Introduced in [34903].

Attachments (2)

34274_a.diff (2.4 KB) - added by swissspidy 10 years ago.
Option A: Check for SimpleXML availability
34274_b.diff (10.3 KB) - added by swissspidy 10 years ago.
Option B: Remove XML endpoint completely

Download all attachments as: .zip

Change History (13)

#1 @DrewAPicture
10 years ago

  • Priority changed from normal to high

#2 @swissspidy
10 years ago

In which other places does core generate XML data? It would be great to have 1 standard function or class to generate XML.

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


10 years ago

#4 @swissspidy
10 years ago

As discussed in the dev chat, string building might be the only option here. I've chatted with @rmccue about this before, so it'd be great to have his opinion on this.

Notes:

There’s a WXR CDATA function we may want to have wrap something more general if we want to use it.

Last resort:

Another option would be to remove XML support from the oEmbed endpoint.

#5 @johnbillion
10 years ago

Adding to the list of options: require SimpleXML for XML oEmbed endpoints, return a 501 if it's been disabled.

#6 @rmccue
10 years ago

We build XML via string manipulation in a lot of places (urgh), so that's an option, albeit a sucky one. If we do that, we need to be extremely careful about sanitisation, and not producing invalid UTF-8.

I'd prefer not to; I think we could probably get away with a 501, since I'd expect lots of people are using JSON anyway. It's optional per the oEmbed spec anyway. (We could probably remove all of the XML handling if we really wanted; @swissspidy would know more about compatibility though.)

@swissspidy
10 years ago

Option A: Check for SimpleXML availability

@swissspidy
10 years ago

Option B: Remove XML endpoint completely

#7 @swissspidy
10 years ago

  • Keywords has-patch 2nd-opinion added; needs-patch removed

We originally added XML support to the plugin because it seemed easy to do so. Before that, we sent a 501 when requesting something else than JSON.

Using string building isn't my favorite option. Checking for SimpleXML and sending a 501 if it isn't available is easier (see 34274_a.diff).

However, I don't think there really are many people using XML for oEmbed. Removing that completely would simplify many parts of the oEmbed functionality (see 34274_b.diff). If someone really wants XML, I can write a plugin for that.

When considering that the REST API is JSON-only and we might use that for the endpoint (see #34207), encouraging users to use JSON would make even more sense.

#8 @Viper007Bond
10 years ago

I think it's worth keeping XML support even if it's the less popular option, but I agree that it's fine to 501 in the event that SimpleXML isn't supported.

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


10 years ago

#10 @swissspidy
10 years ago

  • Keywords commit added; 2nd-opinion removed

Let's go with 34274_a.diff then.

#11 @wonderboymusic
10 years ago

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

In 35354:

oEmbed: if SimpleXMLElement does not exist, return an HTTP Error 501 Not implemented response.

Props swissspidy.
Fixes #34274.

Note: See TracTickets for help on using tickets.