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:
@@ -480,11 +480,11 @@ class _DocumentViewerModalState extends State<DocumentViewerModal> {
|
||||
..src = proxyUrl
|
||||
..setAttribute(
|
||||
'allow',
|
||||
'microphone; camera; usb; autoplay; clipboard-read; clipboard-write',
|
||||
'microphone; camera; usb; autoplay; clipboard-read; clipboard-write; fullscreen',
|
||||
)
|
||||
..setAttribute(
|
||||
'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()
|
||||
|
||||
@@ -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;">
|
||||
<input type="hidden" name="WOPISrc" value="%s">
|
||||
</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>
|
||||
(function() {
|
||||
var form = document.getElementById('collaboraForm');
|
||||
var frame = document.getElementById('collabora-frame');
|
||||
if (form && frame) {
|
||||
console.log('[COLLABORA] Submitting form to Collabora...');
|
||||
form.submit();
|
||||
} else {
|
||||
console.error('[COLLABORA] Form or frame element not found!');
|
||||
}
|
||||
})();
|
||||
window.addEventListener('load', function() {
|
||||
setTimeout(function() {
|
||||
var form = document.getElementById('collaboraForm');
|
||||
if (form) {
|
||||
console.log('[COLLABORA] Form found, submitting...');
|
||||
try {
|
||||
form.submit();
|
||||
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>
|
||||
</body>
|
||||
</html>`, collaboraURL, wopiSrc)
|
||||
|
||||
Reference in New Issue
Block a user