Automattic / Automattic/jetpack

Uploaded image metadata has escaped quotes

Open
#6,119 9 comments 0 reactions 0 assignees View on GitHub
[Feature] WPCOM API [Pri] Normal [Status] Bug Scrub Bug
Dominant language
PHP
Stars
1.8k
Forks
898
Avg merge
1d 18h
Merged PRs (30d)
774

Description

Uploading an image via the [WordPress.com API](https://developer.wordpress.com/docs/api/1.1/post/sites/%24site/media/new/) to a Jetpack blog and setting either the caption or title to a string that includes a single quote results in the quotes being escaped inside WordPress.

#### Steps to reproduce the issue

I'm using the [Lightroom](https://apps.wordpress.com/lightroom/) plugin here which issues a `/media/new` request with the appropriate values set for caption and title. The same effect should be reproducable via other means (I reproduced it using curl)

1. Export a photo to a WordPress.com blog with a title and caption that includes a single quote. Note that the media library correctly shows the values:

![media_library_ _testomattic_site_s_ _wordpress](https://cloud.githubusercontent.com/assets/1277682/22057039/eb0ee12c-dd5a-11e6-87cf-ce80d8a9fa6c.jpg)

2. Export the same photo with the same title/caption to a Jetpack site and note that the media library shows escaped values:

![gfd](https://cloud.githubusercontent.com/assets/1277682/22057099/238a75d4-dd5b-11e6-8b24-2aab8a4e1121.jpg)

This is using Jetpack 4.5, WP 4.7.1, and PHP 7.0. The same behaviour has been seen on another host with PHP 5.6 and the same WP and Jetpack 4.4.2.

I'm not sure whether the problem is in the Jetpack plugin itself, or in the Jetpack part of the API, but I'm logging it here as it only affects Jetpack blogs.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue with a /media/new request using curl, a title, and a caption containing a single quote, then compare Jetpack and WordPress.com behavior. Trace the Jetpack-side API handling for those fields and determine where the extra escaping is introduced; done means the Jetpack media library displays the original quote without escaping.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.