Fix: Pass WOPISrc directly to form submission, don't build URL with query params

- Remove URL building with query parameters that was causing GET requests
- Pass WOPISrc directly to _buildCollaboraIframe function
- JavaScript now creates form with POST method and WOPISrc in body
- This ensures Collabora receives POST not GET request
This commit is contained in:
Leon Bösche
2026-01-12 15:28:50 +01:00
parent 89f55471ce
commit 99419748bb

View File

@@ -403,17 +403,8 @@ class _DocumentViewerModalState extends State<DocumentViewerModal> {
final wopiSession = snapshot.data!; final wopiSession = snapshot.data!;
// Build Collabora Online viewer URL with WOPISrc // Don't build URL with query parameters - pass WOPISrc separately to JavaScript
// The WOPISrc must be URL-encoded and kept encoded return _buildWebView(wopiSession.wopisrc);
// We use a double-encoding approach: encodeComponent keeps it encoded through iframe.src
final baseUrl =
'https://of.b0esche.cloud/loleaflet/dist/loleaflet.html';
final collaboraUrl = Uri.parse(
baseUrl,
).replace(queryParameters: {'WOPISrc': wopiSession.wopisrc}).toString();
// Use WebView to display Collabora Online
return _buildWebView(collaboraUrl);
}, },
); );
} }
@@ -457,16 +448,12 @@ class _DocumentViewerModalState extends State<DocumentViewerModal> {
} }
} }
Widget _buildCollaboraIframe(String collaboraUrl) { Widget _buildCollaboraIframe(String wopisrc) {
// For Collabora Online, we need to POST the WOPISrc, not GET it // For Collabora Online, we need to POST the WOPISrc, not GET it
// Use JavaScript to create and submit the form properly // Use JavaScript to create and submit the form properly
final String viewType = 'collabora-form-${DateTime.now().millisecondsSinceEpoch}'; final String viewType = 'collabora-form-${DateTime.now().millisecondsSinceEpoch}';
ui.platformViewRegistry.registerViewFactory(viewType, (int viewId) { ui.platformViewRegistry.registerViewFactory(viewType, (int viewId) {
// Extract the WOPISrc from the URL
final uri = Uri.parse(collaboraUrl);
final wopisrc = uri.queryParameters['WOPISrc'] ?? '';
// Create a container for the form and iframe // Create a container for the form and iframe
final container = html.DivElement() final container = html.DivElement()
..style.width = '100%' ..style.width = '100%'
@@ -531,9 +518,9 @@ class _DocumentViewerModalState extends State<DocumentViewerModal> {
return HtmlElementView(viewType: viewType); return HtmlElementView(viewType: viewType);
} }
Widget _buildWebView(String url) { Widget _buildWebView(String wopisrc) {
// Embed Collabora Online in an iframe for web platform // Embed Collabora Online in an iframe for web platform
return _buildCollaboraIframe(url); return _buildCollaboraIframe(wopisrc);
} }
@override @override