Fix: Use proper URL building for Collabora WOPISrc parameter

- Changed from manual string concatenation to Uri.parse().replace(queryParameters: ...)
- This properly encodes the WOPISrc while maintaining encoding through iframe.src
- Fixes Collabora 'WOPISrc validation error: unencoded WOPISrc' warning
- Uri API ensures query parameters are properly percent-encoded
This commit is contained in:
Leon Bösche
2026-01-12 10:12:58 +01:00
parent 69cf328972
commit 0b822af438

View File

@@ -404,10 +404,12 @@ class _DocumentViewerModalState extends State<DocumentViewerModal> {
final wopiSession = snapshot.data!;
// Build Collabora Online viewer URL with WOPISrc
// The WOPISrc must be URL-encoded since it contains special characters (://, ?, =, &)
final encodedWopisrc = Uri.encodeComponent(wopiSession.wopisrc);
final collaboraUrl =
'https://of.b0esche.cloud/loleaflet/dist/loleaflet.html?WOPISrc=$encodedWopisrc';
// The WOPISrc must be URL-encoded and kept encoded
// 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);