Skip to content

Commit

Permalink
Fix double-decoding in XMLRPC putAttachment
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianheine committed Oct 30, 2011
1 parent 3629bc8 commit 80d6fbc
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/exe/xmlrpc.php
Expand Up @@ -7,7 +7,7 @@
/**
* Increased whenever the API is changed
*/
define('DOKU_XMLRPC_API_VERSION',5);
define('DOKU_XMLRPC_API_VERSION', 6);

require_once(DOKU_INC.'inc/init.php');
session_write_close(); //close session
Expand Down Expand Up @@ -584,8 +584,12 @@ function putAttachment($id, $file, $params) {

// save temporary file
@unlink($ftmp);
$buff = base64_decode($file);
io_saveFile($ftmp, $buff);
if (preg_match('/^[A-Za-z0-9\+\/]*={0,2}$/', $file) === 1) {
// DEPRECATED: Double-decode file if it still looks like base64
// after first decoding (which is done by the library)
$file = base64_decode($file);
}

This comment has been minimized.

Copy link
@splitbrain

splitbrain Mar 23, 2012

Collaborator

This would probably break any pure ASCII attachment as it would be decoded again here. I just merged the new API abstractions by @dom-mel which do not contain these changes and I think we should leave them out. Clients can check the API version and behave accordingly.

io_saveFile($ftmp, $file);

$res = media_save(array('name' => $ftmp), $id, $params['ow'], $auth, 'rename');
if (is_array($res)) {
Expand Down

0 comments on commit 80d6fbc

Please sign in to comment.