Open johngodley opened 7 years ago
Related: #5505
I tried to replicate this issue. I tried both with the latest Jetpack from the repo, and with Jetpack 4.5. I tried with WordPress 4.7.2, and with WordPress 4.7.1. All on PHP 7.0... and I can't replicate the issue.
I used the following query in the WP developer console:
... which correctly filled in the title and caption:
@johngodley, you mentioned that you managed to replicate the issue in cURL. Would you be able to send me what your cURL POST body looked like? Please make sure you leave out any authorization headers. I am particularly interested to see the attrs
in your request.
I think this only occurs when you upload the image directly, rather than with media_urls
.
This is what I'm using on a Jetpack site:
curl --form 'media[]=@lemon.jpg' --form "attrs[0][title]=title's" --form "attrs[0][caption]=This will be the caption's for file1.jpg" -H 'Authorization: BEARER XXX 'https://public-api.wordpress.com/rest/v1/sites/urbangiraffe.com/media/new' -i -v
Which results in:
{"media":[{"id":"1351","date":"2017-02-10T08:15:09+00:00","parent":0,"link":"\/images\/blog\/2017\/02\/lemon.jpg","title":"title\\'s","caption":"This will be the caption\\'s for file1.jpg"
Note the \\
in the title and caption.
Strangely when I do this against a WP.com site the title and caption are ignored.
This issue has been marked as stale. This happened because:
No further action is needed. But it's worth checking if this ticket has clear reproduction steps and it is still reproducible. Feel free to close this issue if you think it's not valid anymore — if you do, please add a brief explanation.
This issue is still occurring. I spent a while trying to identify the source of those quotes, till discovering they only appear on image attributes in Jetpack sites, not on WordPress.com sites.
Is there a chance of this getting resolved? Is there a workaround to adding image attributes without those quotes that works on both Jetpack and WP.com sites?
Cheers!
Adi
@designsimply @johngodley @jeherve @thingalon
Hey folks, is there any chance of any work happening on this bug? Or a known workaround? I'll really appreciate any help!
Cheers!
Adi
@adityabhaskar We are not working on this part of plugin at the moment, but we'll update this issue as soon as we start working on this.
@jeherve Thanks for the update!
Do you accept outside contributions? If yes, and if you could guide me to the part of the code base related to this issue, I could have a go at resolving this.
Cheers!
Adi
We do, yes. The WordPress.com REST API lives in different places though, so I can't really tell you exactly where the problem comes from and where it can be solved without investigating further.
Uploading an image via the WordPress.com API 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 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)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.