Make WordPress Core

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#20984 closed defect (bug) (invalid)

XMLRPC: wp.uploadFile missing base64_decode

Reported by: fishc4ke's profile fishc4ke Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.4
Component: XML-RPC Keywords:
Focuses: Cc:

Description

Uploading images via wp.uploadFile results in a broken image as the base64 bits are not decoded again.

Looking at the code, the file is written to disk by the function wp_upload_bits in functions.php.

A fix would be to alter line 1615 of functions.php:

@fwrite( $ifp, $bits );

to

@fwrite( $ifp, base64_decode($bits) );

However, I have not tested to see if this would break any other functionality.

Change History (7)

#1 @maxcutler
12 years ago

  • Cc maxcutler added

I am unable to reproduce this, can you please provide more details?

$bits is actually binary data by that point, since IXR_Message will call base64_decode before mw_newMediaObject (wp.uploadFile) is ever called. See L303 of wp-includes/class-IXR.php.

#2 @fishc4ke
12 years ago

The codex page states that bits' needs to be a base64-encoded, so I am simply opening the file and base64-encoding its contents (via Python 2.7.3) before uploading.

#3 @maxcutler
12 years ago

Can you supply the exact XML-RPC request you are sending to WordPress? If you are using the base64 value type as defined in the spec, then it should be doing the Right Thing.

If you are using Python's xmlrpclib, you can take a look at my python wrapper library to see the correct way to handle binary data.

#4 @fishc4ke
12 years ago

I've had another look at my code, found the issue. Bug in my code and as I was looking through the WP code I jumped to conclusions. tl;dr I'm an idiot.

#5 @maxcutler
12 years ago

  • Resolution set to invalid
  • Status changed from new to closed

#6 @SergeyBiryukov
12 years ago

  • Milestone Awaiting Review deleted

#7 @SergeyBiryukov
12 years ago

#23137 was marked as a duplicate.

Note: See TracTickets for help on using tickets.