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:
@@ -404,10 +404,12 @@ class _DocumentViewerModalState extends State<DocumentViewerModal> {
|
|||||||
final wopiSession = snapshot.data!;
|
final wopiSession = snapshot.data!;
|
||||||
|
|
||||||
// Build Collabora Online viewer URL with WOPISrc
|
// Build Collabora Online viewer URL with WOPISrc
|
||||||
// The WOPISrc must be URL-encoded since it contains special characters (://, ?, =, &)
|
// The WOPISrc must be URL-encoded and kept encoded
|
||||||
final encodedWopisrc = Uri.encodeComponent(wopiSession.wopisrc);
|
// We use a double-encoding approach: encodeComponent keeps it encoded through iframe.src
|
||||||
final collaboraUrl =
|
final baseUrl = 'https://of.b0esche.cloud/loleaflet/dist/loleaflet.html';
|
||||||
'https://of.b0esche.cloud/loleaflet/dist/loleaflet.html?WOPISrc=$encodedWopisrc';
|
final collaboraUrl = Uri.parse(baseUrl)
|
||||||
|
.replace(queryParameters: {'WOPISrc': wopiSession.wopisrc})
|
||||||
|
.toString();
|
||||||
|
|
||||||
// Use WebView to display Collabora Online
|
// Use WebView to display Collabora Online
|
||||||
return _buildWebView(collaboraUrl);
|
return _buildWebView(collaboraUrl);
|
||||||
|
|||||||
Reference in New Issue
Block a user