Fix Collabora form submission: remove iframe target and use _self to bypass CSP

This commit is contained in:
Leon Bösche
2026-01-13 12:59:49 +01:00
parent 19825763ad
commit 8baaad2c08

View File

@@ -666,7 +666,8 @@ func collaboraProxyHandler(w http.ResponseWriter, r *http.Request, db *database.
wopiSrc := fmt.Sprintf("https://go.b0esche.cloud/wopi/files/%s?access_token=%s", fileID, accessToken) wopiSrc := fmt.Sprintf("https://go.b0esche.cloud/wopi/files/%s?access_token=%s", fileID, accessToken)
// Return HTML page with auto-submitting form // Return HTML page with auto-submitting form
// Collabora Online: POST WOPISrc as form data // The form POSTs to Collabora from within an iframe to work around CSP frame-ancestors restrictions
// The iframe is hosted on the same domain as the embedded page, allowing the POST to complete
htmlContent := fmt.Sprintf(`<!DOCTYPE html> htmlContent := fmt.Sprintf(`<!DOCTYPE html>
<html> <html>
<head> <head>
@@ -683,22 +684,18 @@ func collaboraProxyHandler(w http.ResponseWriter, r *http.Request, db *database.
<div class="loading"> <div class="loading">
<p>Loading Collabora Online...</p> <p>Loading Collabora Online...</p>
</div> </div>
<form method="POST" action="%s/browser/dist/cool.html" target="collabora-frame" id="collaboraForm" style="display: none;"> <form method="POST" action="%s/browser/dist/cool.html" target="_self" 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="position:fixed; top:0; left:0; width:100%%; height:100%%; border:none;"></iframe>
<script> <script>
window.addEventListener('load', function() { // Auto-submit the form to Collabora
setTimeout(function() {
var form = document.getElementById('collaboraForm'); var form = document.getElementById('collaboraForm');
if (form) { if (form) {
console.log('[COLLABORA] Submitting form to /browser/dist/cool.html'); console.log('[COLLABORA] Submitting form to /browser/dist/cool.html with WOPISrc');
form.submit(); form.submit();
} else { } else {
console.error('[COLLABORA] Form not found'); console.error('[COLLABORA] Form not found');
} }
}, 100);
});
</script> </script>
</body> </body>
</html>`, collaboraURL, wopiSrc) </html>`, collaboraURL, wopiSrc)