Bug Description
When downloading/exporting documents from Collabora Online (richdocuments) in the Nextcloud iOS app, the downloadAs JavaScript interface fails to parse the JSON message due to a key name mismatch between the JavaScript side and the iOS side.
Root Cause
JavaScript side (Collabora Online mobile.js wraps the message):
{
"MessageName": "downloadAs",
"Values": {
"url": "https://...",
"format": "pdf"
}
}
iOS side (NCViewerRichDocument.swift:138-140) expects:
guard let type = values["Type"] as? String else { return }
guard let urlString = values["URL"] as? String else { return }
The iOS code uses uppercase keys ("Type", "URL") which don't match what Collabora Online sends ("format", "url"). The guard let statements silently return, causing all downloads to fail.
Affected Code
iOSClient/Viewer/NCViewerRichdocument/NCViewerRichDocument.swift - userContentController(_:didReceive:) method, downloadAs handling block (lines ~135-180)
Reproduction Steps
- Open a document in Collabora Online via the Nextcloud iOS app
- Tap "Export as PDF" (or any other export/download format)
- The download silently does nothing
Expected Behavior
The file should download and present the share/export options sheet.
Proposed Fix
Update userContentController to handle both key naming conventions:
if let values = param["Values"] as? [AnyHashable: Any] {
// Support both old ("Type"/"URL") and new ("format"/"url") key formats
let type = values["Type"] as? String ?? values["format"] as? String
let urlString = values["URL"] as? String ?? values["url"] as? String
guard let type = type, let urlString = urlString else { return }
guard let url = URL(string: urlString) else { return }
// ... rest of the logic
}
Related
Bug Description
When downloading/exporting documents from Collabora Online (richdocuments) in the Nextcloud iOS app, the
downloadAsJavaScript interface fails to parse the JSON message due to a key name mismatch between the JavaScript side and the iOS side.Root Cause
JavaScript side (Collabora Online
mobile.jswraps the message):{ "MessageName": "downloadAs", "Values": { "url": "https://...", "format": "pdf" } }iOS side (
NCViewerRichDocument.swift:138-140) expects:The iOS code uses uppercase keys (
"Type","URL") which don't match what Collabora Online sends ("format","url"). Theguard letstatements silently return, causing all downloads to fail.Affected Code
iOSClient/Viewer/NCViewerRichdocument/NCViewerRichDocument.swift-userContentController(_:didReceive:)method,downloadAshandling block (lines ~135-180)Reproduction Steps
Expected Behavior
The file should download and present the share/export options sheet.
Proposed Fix
Update
userContentControllerto handle both key naming conventions:Related