Collabora + Nextcloud 21 - Paste issue
Describe the bug Unable to paste data from outside a document (calc or writter). But copy/paste works with data from the document itself
To Reproduce Steps to reproduce the behavior:
- Open any document (odt, ods,xlsx, docx)
- Copy data from another browser tab, or any other application 3.Ctrl + V inside a collabora window
- Nothing happens
- Open Developper window on browser and see :
XHRPOSThttps://xxxxxx.com/custom_apps/richdocumentscode/proxy.php?req=/lool/clipboard?WOPISrc=https://xxxx.com/index.php/apps/richdocuments/wopi/files/120740_oc2g7swypbql&ServerId=b17b7c5c&ViewId=0&Tag=1ee51f1a8e6a484e
[HTTP/2 400 Bad Request 133ms]
POST
https://xxxx.com/custom_apps/richdocumentscode/proxy.php?req=/lool/clipboard?WOPISrc=https://xxxx.com/index.php/apps/richdocuments/wopi/files/120740_oc2g7swypbql&ServerId=b17b7c5c&ViewId=0&Tag=1ee51f1a8e6a484e
État
400
Bad Request
VersionHTTP/2
Transfert2,28 Ko (taille 0 o)
Politique de référentno-referrer
HTTP/2 400 Bad Request
server: nginx/1.17.3
date: Thu, 04 Nov 2021 07:54:44 GMT
content-type: text/html; charset=UTF-8
content-length: 0
referrer-policy: no-referrer
x-content-type-options: nosniff
x-download-options: noopen
x-frame-options: SAMEORIGIN
x-permitted-cross-domain-policies: none
x-robots-tag: none
x-xss-protection: 1; mode=block
x-powered-by: PHP/7.4.23
user-agent: LOOLWSD WOPI Agent
strict-transport-security: max-age=31536000
X-Firefox-Spdy: h2
Accept
*/*
Accept-Encoding
gzip, deflate, br
Accept-Language
fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3
Connection
keep-alive
Content-Length
784
Content-Type
multipart/form-data; boundary=---------------------------24844005621174620321911931571
Cookie
__Host-nc_sameSiteCookielax=true; __Host-nc_sameSiteCookiestrict=true; nc_sameSiteCookielax=true; nc_sameSiteCookiestrict=true; oc2g7swypbql=96d50cf7fa76cd4375d8b5286c386fba; oc_sessionPassphrase=OPi5lFES%2BGq0B04BVPxvojsR6f4vFw3INjYIbjAgAO4%2Fxd7NjCL8AfFuBvmjQ6SwWSRVZM2wG4xSpPLISBdfxwg%2B03hkTM8nUgaViNWd0zf5gBQBW2YmfkdzugxhQrsl
Host
xxxx.com
Origin
https://xxxx.com
Sec-Fetch-Dest
empty
Sec-Fetch-Mode
cors
Sec-Fetch-Site
same-origin
TE
trailers
User-Agent
Mozilla/5.0 (X11; Linux x86_64; rv:93.0) Gecko/20100101 Firefox/93.0
Expected behavior I expect pasting data is working
Client details:
- OS: any
- Browser chrome, firefox, edge
- Version [e.g. 22] : any
- Device: [e.g. iPhone6, desktop] : any
Server details
Docker build 20.10.7 on linux, amd64 Image : sha256:89968192a24c637ac07049c1ee63315eb13d7dc23c0944588dffad7d8ef94136 Operating system: Linux Web server: apache Database: MySQL 5.7 PHP version: 7.4.23 Nextcloud version: 21.0.4 Version of the richdocuments app 4.2.3 Version of Collabora Online 6.4.1303
Logs
Nextcloud log (data/nextcloud.log)
No log available for this error
Browser log
XHRPOSThttps://xxxxxx.com/custom_apps/richdocumentscode/proxy.php?req=/lool/clipboard?WOPISrc=https://xxxxxx.com/index.php/apps/richdocuments/wopi/files/120740_oc2g7swypbql&ServerId=b17b7c5c&ViewId=0&Tag=6e1d148f87e79d65
[HTTP/2 400 Bad Request 156ms]
POST
https://xxxxxxx.com/custom_apps/richdocumentscode/proxy.php?req=/lool/clipboard?WOPISrc=https://xxxxxx.com/index.php/apps/richdocuments/wopi/files/120740_oc2g7swypbql&ServerId=b17b7c5c&ViewId=0&Tag=6e1d148f87e79d65
État
400
Bad Request
VersionHTTP/2
Transfert3,47 Ko (taille 0 o)
Politique de référentno-referrer
Accept
*/*
Accept-Encoding
gzip, deflate, br
Accept-Language
fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3
Connection
keep-alive
Content-Length
1999
Content-Type
multipart/form-data; boundary=---------------------------40574860214393289532532857991
Cookie
__Host-nc_sameSiteCookielax=true; __Host-nc_sameSiteCookiestrict=true; nc_sameSiteCookielax=true; nc_sameSiteCookiestrict=true; oc2g7swypbql=96d50cf7fa76cd4375d8b5286c386fba; oc_sessionPassphrase=OPi5lFES%2BGq0B04BVPxvojsR6f4vFw3INjYIbjAgAO4%2Fxd7NjCL8AfFuBvmjQ6SwWSRVZM2wG4xSpPLISBdfxwg%2B03hkTM8nUgaViNWd0zf5gBQBW2YmfkdzugxhQrsl
Host
xxxxxx.com
Origin
https://xxxxxxxx.com
Sec-Fetch-Dest
empty
Sec-Fetch-Mode
cors
Sec-Fetch-Site
same-origin
TE
trailers
User-Agent
Mozilla/5.0 (X11; Linux x86_64; rv:93.0) Gecko/20100101 Firefox/93.0
Same behavior with NC Version 22.2.0.
Usability is rather limited without copy & past functionality. I can also confirm that this problem exists in firefox (94.0) and chrome (94.0.4606.81)
Same issue here, we have: Nextcloud 23 Collabora Online 4.2.3 Collabora Online - Built-in CODE Server 21.11.103
When pasting (Tried Word and Excel) via CTRL+V nothing happens. I checked the Browser Console, no errors. Under the Network activity i see when i press CTRL+V that a POST is made:
But the text in the clipboard does not arrive in the editor.
Same issue here. Already checked my security headers, that's not the problem.
Tested on:
Chrome
- OS: Windows 10
- Browser: Chrome
- Version 97.0.4692.99
- Device: Desktop
Firefox
- OS: Windows 10
- Browser: Firefox
- Version 91.5.0esr
- Device: Desktop
Server details
Operating system: Debian 10, running Nextcloud in Docker with the official image from https://hub.docker.com/_/nextcloud
Web server: nginx:1.21.4
Database: mariadb:10.5.13
PHP version: 8.0.15
Nextcloud version: Nextcloud Hub II (23.0.0)
Version of the Collabora Online - Built-in CODE Server app 21.11.103
Version of Collabora Online: 5.0.1
Logs
Nextcloud log (data/nextcloud.log)
Full of similar messages like below:
{"reqId":"id","level":3,"time":"2022-01-27T13:47:21+00:00","remoteAddr":"1.2.3.4","user":"example","app":"richdocuments","method":"POST","url":"/index.php/apps/richdocuments/wopi/files/147260_ocys7t2crhy0/contents?access_token=exampleToken&access_token_ttl=exampleToken&compat=","message":"getFile failed","userAgent":"COOLWSD HTTP Agent 21.11.1.3","version":"23.0.0.10","exception":{"Exception":"OCP\\Files\\NotFoundException","Message":"No valid file found for wopi token","Code":0,"Trace":[{"file":"/var/www/html/custom_apps/richdocuments/lib/Controller/WopiController.php","line":485,"function":"getFileForWopiToken","class":"OCA\\Richdocuments\\Controller\\WopiController","type":"->","args":[{"__class__":"OCA\\Richdocuments\\Db\\Wopi","id":344}]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":217,"function":"putFile","class":"OCA\\Richdocuments\\Controller\\WopiController","type":"->","args":["147260","cKMl3upCEYGDdm4UZyDhZzs3yCE9tAin"]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":126,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\Richdocuments\\Controller\\WopiController"},"putFile"]},{"file":"/var/www/html/lib/private/AppFramework/App.php","line":157,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\Richdocuments\\Controller\\WopiController"},"putFile"]},{"file":"/var/www/html/lib/private/Route/Router.php","line":302,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["OCA\\Richdocuments\\Controller\\WopiController","putFile",{"__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"},{"fileId":"147260_ocys7t2crhy0","_route":"richdocuments.wopi.putFile"}]},{"file":"/var/www/html/lib/base.php","line":1006,"function":"match","class":"OC\\Route\\Router","type":"->","args":["/apps/richdocuments/wopi/files/147260_ocys7t2crhy0/contents"]},{"file":"/var/www/html/index.php","line":36,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"/var/www/html/custom_apps/richdocuments/lib/Controller/WopiController.php","Line":716,"CustomMessage":"getFile failed"}}
Browser log
a) Console Log, paste from within the document itself [WORKING]
[document] Received post message
Object { msgId: "Doc_ModifiedStatus", args: {…}, deprecated: false }
document.js:339:13
PostMessageService.sendPostMessage parent {"MessageId":"Doc_ModifiedStatus","SendTime":1643291525569,"Values":{"Modified":true}} postMessage.tsx:57:10
[document] Unhandled post message
Object { msgId: "Doc_ModifiedStatus", args: {…}, deprecated: false }
document.js:439:14
[viewer] Received post message
Object { msgId: "Doc_ModifiedStatus", args: {…}, deprecated: false }
Office.vue:214
b) Console Log, paste from outside of the document [NOT WORKING]
[document] Received post message
Object { msgId: "Doc_ModifiedStatus", args: {…}, deprecated: false }
document.js:339:13
PostMessageService.sendPostMessage parent {"MessageId":"Doc_ModifiedStatus","SendTime":1643291768202,"Values":{"Modified":true}} postMessage.tsx:57:10
[document] Unhandled post message
Object { msgId: "Doc_ModifiedStatus", args: {…}, deprecated: false }
document.js:439:14
[viewer] Received post message
Object { msgId: "Doc_ModifiedStatus", args: {…}, deprecated: false }
Office.vue:214
c) Network log Request Header
POST /custom_apps/richdocumentscode/proxy.php?req=/cool/clipboard?WOPISrc=https%3A%2F%2Fexample.de%2Findex.php%2Fapps%2Frichdocuments%2Fwopi%2Ffiles%2F147791_ocys7t2crhy0&ServerId=4d43ff27&ViewId=0&Tag=550acfa666979657 HTTP/1.1
Host: example.de
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Content-Type: multipart/form-data; boundary=---------------------------371574510910263928372187013832
Content-Length: 248
Origin: https://example.de
DNT: 1
Connection: keep-alive
Cookie: __Host-nc_sameSiteCookielax=true; __Host-nc_sameSiteCookiestrict=true; nc_username=exmapleUser; nc_token=exampleNcToken; nc_session_id=exampleNcSessionId; oc_sessionPassphrase=exampleSessionPassphrase; ocys7t2crhy0=example
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
Pragma: no-cache
Cache-Control: no-cache
Request payload
-----------------------------371574510910263928372187013832
Content-Disposition: form-data; name="file"; filename="blob"
Content-Type: application/octet-stream
text/plain
4
Test
-----------------------------371574510910263928372187013832--
Response Header
HTTP/2 200 OK
server: nginx
date: Thu, 27 Jan 2022 14:13:56 GMT
content-type: text/html; charset=UTF-8
content-length: 229
referrer-policy: no-referrer
x-content-type-options: nosniff
x-download-options: noopen
x-frame-options: SAMEORIGIN
x-permitted-cross-domain-policies: none
x-robots-tag: none
x-xss-protection: 1; mode=block
x-powered-by: PHP/8.0.15
vary: Accept-Encoding
content-encoding: gzip
strict-transport-security: max-age=63072000
expect-ct: enforce, max-age=21600
X-Firefox-Spdy: h2
Response
<br />
<b>Warning</b>: Undefined array key "Content-Type" in <b>/var/www/html/custom_apps/richdocumentscode/proxy.php</b> on line <b>346</b><br />
<br />
<b>Warning</b>: Undefined array key 1 in <b>/var/www/html/custom_apps/richdocumentscode/proxy.php</b> on line <b>347</b><br />
<br />
<b>Warning</b>: Cannot modify header information - headers already sent by (output started at /var/www/html/custom_apps/richdocumentscode/proxy.php:346) in <b>/var/www/html/custom_apps/richdocumentscode/proxy.php</b> on line <b>173</b><br />
<br />
<b>Warning</b>: Cannot modify header information - headers already sent by (output started at /var/www/html/custom_apps/richdocumentscode/proxy.php:346) in <b>/var/www/html/custom_apps/richdocumentscode/proxy.php</b> on line <b>173</b><br />
<br />
<b>Warning</b>: Cannot modify header information - headers already sent by (output started at /var/www/html/custom_apps/richdocumentscode/proxy.php:346) in <b>/var/www/html/custom_apps/richdocumentscode/proxy.php</b> on line <b>173</b><br />
<br />
<b>Warning</b>: Cannot modify header information - headers already sent by (output started at /var/www/html/custom_apps/richdocumentscode/proxy.php:346) in <b>/var/www/html/custom_apps/richdocumentscode/proxy.php</b> on line <b>173</b><br />
<br />
<b>Warning</b>: Cannot modify header information - headers already sent by (output started at /var/www/html/custom_apps/richdocumentscode/proxy.php:346) in <b>/var/www/html/custom_apps/richdocumentscode/proxy.php</b> on line <b>173</b><br />
We are currently facing the same issue, with nextcloud 22.2.3 and collabora 21.11.3. Testing was done on chromium as well as firefox, on windows and linux.
COOLWSD: 21.11.2.4 LOKit: Collabora Office 21.06.20.1 Ubuntu Server 20.04.4 LTS Nextcloud 23.0.3
Same behavior here, this is the output head developers of Firefox::
XHR POST https://xxxxxx.com/cool/clipboard?WOPISrc=https://xxxxxx.com/nextcloud/index.php/apps/richdocuments/wopi/files/5687597_ocxjw9hicgve&ServerId=cd77ccf3&ViewId=0&Tag=390de40e44db5d1e
Scheme: https Host: xxxxxx.com Filename: /cool/clipboard
WOPISrc: https://xxxxxx.com/nextcloud/index.php/apps/richdocuments/wopi/files/5687597_ocxjw9hicgve ServerId: cd77ccf3 ViewId: 0 Tag: 390de40e44db5d1e
Dirección: xxx.xxx.xxx.xxx:443
Estado 400 Bad Request Versión HTTP/1.1 Transferido 1,29 KB (tamaño 0 B) Política de referencia no-referrer
HTTP/1.1 400 Bad Request Date: Wed, 30 Mar 2022 11:19:04 Server: COOLWSD HTTP Server 21.11.2.4 Strict-Transport-Security: max-age=15768000; includeSubDomains; preload Content-Length: 0 Connection: close
POST /cool/clipboard?WOPISrc=https%3A%2F%2F HTTP/1.1 Host: xxxxxx.com User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:98.0) Gecko/20100101 Firefox/98.0 Accept: / Accept-Language: es-ES,es;q=0.5 Accept-Encoding: gzip, deflate, br Content-Type: multipart/form-data; boundary=---------------------------2056929430972252333160773682 Content-Length: 247 Origin: https://xxxxxx.com DNT: 1 Sec-Fetch-Dest: empty Sec-Fetch-Mode: cors Sec-Fetch-Site: same-origin Connection: keep-alive Cookie: DOLUSERCOOKIE_boxfilter_task=all; theme_cookie=black-theme; opcachegui=true; DOLSESSID_a8d7bb5ee1939727701f4fd8abf1e808=kf6uue38bfmfm67ftfmuiou4qt; geopos=MzcuMzU4Nzk2OCwtNi4yMDYyNTkyLDI1MjYuNjgzNzE0MDcxODc4
Can confirm the issue with Collabora inside Nextcloud. Copy and Paste from outside of Collabora is not working. Tested on Chromium, Chrome and Firefox on Windows and Ubuntu. Collabora Code Version: 21.11.3.6 Nextcloud Version: 22.2.6
I am having a similar issue. Have you guys looked in your nginx collabora error logs? Mine shows this:
[error] 831#831: *942398 open() "/usr/share/nginx/html/cool/clipboard" failed (2: No such file or directory), client: 217.35.225.146, server: o<domain>, request: "POST /cool/clipboard?WOPISrc=https%3A%2F%2F<domain>%2Findex.php%2Fapps%2Frichdocuments%2Fwopi%2Ffiles%2F340910_oceyq4ovwzku&ServerId=d09e7145&ViewId=0&Tag=f439614cc17f5087 HTTP/2.0", host: "<domain>"
It seems nginx is defaulting to a non-existent path. Is there a missing endpoint I should be including in my collabora nginx config?
EDIT: This error does NOT happen when I paste a screenshot put in the clipboard by the OS (works in Windows 10 and Ubuntu 20.04). It does happen whenever I try to paste anything else copied from anywhere else (and consistently fails on both Windows 10 and Ubuntu 20.04). It seems the nginx config matches /cool/clipboard for screenshot pasting but doesn't match it for anything else - very confusing.
EDIT2: Fixed - My nginx config had an endpoint configured as ^(c|l)ool instead of ^/(c|l)ool.
Did you fixed the overall paste issue or did you only fix your specific nginx error?
Did you fixed the overall paste issue or did you only fix your specific nginx error?
I fixed my paste issue, so pasting works now for me, but not sure if it was the exact same cause as the OP's.
If i copy the text from outside into the excel, it will show the message.

If i copy the text from outside into the excel, it will show the message.
+1 (Docker and 24.0.3 image)
Inspecting proxy logs is a good idea, my problem with copy+paste solved by increasing client_max_body_size
Thanks for the info @petrov-it but this is not the issue in my case at least. No errors from my nginx proxy, and client_max-body_size was set to 1G.
"POST /custom_apps/richdocumentscode/proxy.php?req=/cool/clipboard?WOPISrc=https%3A%2F%2F<domain>%2Findex.php%2Fapps%2Frichdocuments%2Fwopi%2Ffiles%2F5972834_ocak7ofs07qf&ServerId=923011d3&ViewId=0&Tag=290e76c2c0584331 HTTP/1.1" 200 656 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:106.0) Gecko/20100101 Firefox/106.0"
This is the log from the actual nextcloud container behind the nginx proxy.
Hi, i got the same error, with the same logs
problem persists in 24.0.7
The HTTP request which is triggered through the CTRL+V returns the following error:
https://nextcloud.example.com/custom_apps/richdocumentscode/proxy.php?req=/cool/clipboard?WOPISrc=https://nextcloud.example.com/index.php/apps/richdocuments/wopi/files/123456&ServerId=7890&ViewId=0&Tag=aabbccddeeff
<br />
<b>Warning</b>: Undefined array key "Content-Type" in <b>/var/www/html/custom_apps/richdocumentscode/proxy.php</b> on line <b>347</b><br />
<br />
<b>Warning</b>: Undefined array key 1 in <b>/var/www/html/custom_apps/richdocumentscode/proxy.php</b> on line <b>348</b><br />
<br />
<b>Warning</b>: Cannot modify header information - headers already sent by (output started at /var/www/html/custom_apps/richdocumentscode/proxy.php:347) in <b>/var/www/html/custom_apps/richdocumentscode/proxy.php</b> on line <b>174</b><br />
<br />
<b>Warning</b>: Cannot modify header information - headers already sent by (output started at /var/www/html/custom_apps/richdocumentscode/proxy.php:347) in <b>/var/www/html/custom_apps/richdocumentscode/proxy.php</b> on line <b>174</b><br />
<br />
<b>Warning</b>: Cannot modify header information - headers already sent by (output started at /var/www/html/custom_apps/richdocumentscode/proxy.php:347) in <b>/var/www/html/custom_apps/richdocumentscode/proxy.php</b> on line <b>174</b><br />
<br />
<b>Warning</b>: Cannot modify header information - headers already sent by (output started at /var/www/html/custom_apps/richdocumentscode/proxy.php:347) in <b>/var/www/html/custom_apps/richdocumentscode/proxy.php</b> on line <b>174</b><br />
<br />
<b>Warning</b>: Cannot modify header information - headers already sent by (output started at /var/www/html/custom_apps/richdocumentscode/proxy.php:347) in <b>/var/www/html/custom_apps/richdocumentscode/proxy.php</b> on line <b>174</b><br />
It seems "content-type" needs to be written in lower case letters (output of $headers variable):
Array
(
[Host] => XXXX
[X-Forwarded-Scheme] => https
[X-Forwarded-Proto] => https
[X-Forwarded-For] => XXXXXX
[Connection] => close
[Content-Length] => 210
[sec-ch-ua] => "Google Chrome";v="107", "Chromium";v="107", "Not=A?Brand";v="24"
[sec-ch-ua-platform] => "Windows"
[sec-ch-ua-mobile] => ?0
[user-agent] => Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36
[content-type] => multipart/form-data; boundary=----WebKitFormBoundaryXXXX
[accept] => */*
[origin] => https://XXXX
[sec-fetch-site] => same-origin
[sec-fetch-mode] => cors
[sec-fetch-dest] => empty
[accept-encoding] => gzip, deflate, br
[accept-language] => de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7
[cookie] => xxxx
)
EDIT: Yes, that solved it:

EDIT2: It seems HTTP Headers are case-insensitive and can differ between webservers: https://stackoverflow.com/a/34039108/318765
So the best solution would be to fill the $headers variable with lower-case keys only. As long this is not possible, this could be a workaround:
$type = isset($headers['Content-Type']) ? $headers['Content-Type'] : $headers['content-type'];
The comment from user dinosmm helped me a lot by finding the mistake in my config. Also got error 400. As I updated long time ago from LibreOffice Online to Collabora Online I've got two typos in my config:
# Download as, Fullscreen presentation and Image upload operations
#ProxyPass /cool http://127.0.0.1:9980/lool
#ProxyPassReverse /cool http://127.0.0.1:9980/lool
ProxyPass /cool http://127.0.0.1:9980/cool
ProxyPassReverse /cool http://127.0.0.1:9980/cool
Commented ones are the old ones and last ones are the new ones. Now pasting works like a charm. Hope this helps someone else too.
Hello ! Thank you @mgutt !! Your comment https://github.com/CollaboraOnline/richdocumentscode/issues/148#issuecomment-1329175691 solved my issue. My setup : nextcloud 25.0.3, Built-in CODE server. In Docker on a Synology DSM. Edited file at line 347 : /data/custom_apps/richdocumentscode/proxy.php
Fixed in #208
Released v22.5.802
Can we close this? :)