diff --git a/browser/src/map/Clipboard.js b/browser/src/map/Clipboard.js index 27e306019..f22672b72 100644 --- a/browser/src/map/Clipboard.js +++ b/browser/src/map/Clipboard.js @@ -354,15 +354,15 @@ L.Clipboard = L.Class.extend({ } var formData = new FormData(); - formData.append('data', new Blob([fallbackHtml]), 'clipboard'); + formData.append('data', new Blob([src]), 'clipboard'); that._doAsyncDownload( 'POST', dest, formData, false, function() { if (that._checkAndDisablePasteSpecial()) { - window.app.console.log('up-load of fallback done, now paste special'); + window.app.console.log('up-load of URL done, now paste special'); app.socket.sendMessage('uno .uno:PasteSpecial'); } else { - window.app.console.log('up-load of fallback done, now paste'); + window.app.console.log('up-load of URL done, now paste'); app.socket.sendMessage('uno .uno:Paste'); } diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp index 7a791258e..b5c172393 100644 --- a/wsd/ClientSession.cpp +++ b/wsd/ClientSession.cpp @@ -318,7 +318,24 @@ void ClientSession::handleClipboardRequest(DocumentBroker::ClipboardRequest if (data.get()) { preProcessSetClipboardPayload(*data); - docBroker->forwardToChild(client_from_this(), "setclipboard\n" + *data, true); + + if (data->starts_with("http")) + { + // We got a URL, download that and set the result as the clipboard. + std::shared_ptr httpSession = http::Session::create(*data); + std::shared_ptr httpResponse = + httpSession->syncRequest(http::Request(Poco::URI(*data).getPathAndQuery())); + if (httpResponse->statusLine().statusCode() == http::StatusCode::OK) + { + std::string body = httpResponse->getBody(); + docBroker->forwardToChild(client_from_this(), "setclipboard\n" + body, true); + } + } + else + { + // List of mimetype-size-data tuples, pass that over as-is. + docBroker->forwardToChild(client_from_this(), "setclipboard\n" + *data, true); + } // FIXME: work harder for error detection ? std::ostringstream oss;