Improve Collabora proxy: add load event listener and relax iframe sandbox for form submission

- Use window load event to ensure form element exists before submission
- Add allow-popups-to-escape-sandbox for cross-origin form POSTs
- Add allow-presentation for better compatibility
- Improved error logging for debugging form submission issues
This commit is contained in:
Leon Bösche
2026-01-12 16:51:16 +01:00
parent 18f5b3f98b
commit 5fb08d8831
2 changed files with 19 additions and 13 deletions

View File

@@ -480,11 +480,11 @@ class _DocumentViewerModalState extends State<DocumentViewerModal> {
..src = proxyUrl ..src = proxyUrl
..setAttribute( ..setAttribute(
'allow', 'allow',
'microphone; camera; usb; autoplay; clipboard-read; clipboard-write', 'microphone; camera; usb; autoplay; clipboard-read; clipboard-write; fullscreen',
) )
..setAttribute( ..setAttribute(
'sandbox', 'sandbox',
'allow-same-origin allow-scripts allow-popups allow-forms', 'allow-same-origin allow-scripts allow-popups allow-popups-to-escape-sandbox allow-forms allow-presentation',
); );
final container = html.DivElement() final container = html.DivElement()

View File

@@ -683,18 +683,24 @@ func collaboraProxyHandler(w http.ResponseWriter, r *http.Request, db *database.
<form method="POST" action="%s/loleaflet/dist/loleaflet.html" target="collabora-frame" id="collaboraForm" style="display: none;"> <form method="POST" action="%s/loleaflet/dist/loleaflet.html" target="collabora-frame" id="collaboraForm" style="display: none;">
<input type="hidden" name="WOPISrc" value="%s"> <input type="hidden" name="WOPISrc" value="%s">
</form> </form>
<iframe name="collabora-frame" id="collabora-frame" style="width:100%%; height:100%%; border:none; position:absolute; top:0; left:0;"></iframe> <iframe name="collabora-frame" id="collabora-frame" style="width:100%%; height:100%%; border:none; position:fixed; top:0; left:0;"></iframe>
<script> <script>
(function() { window.addEventListener('load', function() {
var form = document.getElementById('collaboraForm'); setTimeout(function() {
var frame = document.getElementById('collabora-frame'); var form = document.getElementById('collaboraForm');
if (form && frame) { if (form) {
console.log('[COLLABORA] Submitting form to Collabora...'); console.log('[COLLABORA] Form found, submitting...');
form.submit(); try {
} else { form.submit();
console.error('[COLLABORA] Form or frame element not found!'); console.log('[COLLABORA] Form submitted successfully');
} } catch(e) {
})(); console.error('[COLLABORA] Form submission failed:', e);
}
} else {
console.error('[COLLABORA] Form element not found!');
}
}, 100);
});
</script> </script>
</body> </body>
</html>`, collaboraURL, wopiSrc) </html>`, collaboraURL, wopiSrc)