Repository navigation
Closed
Labels
Description
Bug Description
When downloading/exporting documents from Collabora Online (richdocuments) in the Nextcloud Android app, the downloadAs JavaScript interface fails to parse the JSON message due to a key name mismatch between the JavaScript side and the Android side.
Root Cause
JavaScript side (mobile.js wraps the message):
{
"MessageName": "downloadAs",
"Values": {
"url": "https://...",
"format": "pdf"
}
}Android side (RichDocumentsEditorWebView.kt:133-149) expects:
{
"URL": "https://...",
"Type": "pdf"
}The Android code uses downloadJson.getString("URL") and downloadJson.getString("TYPE") which fail because the actual JSON keys are lowercase (url, format).
Affected Code
app/src/main/java/com/owncloud/android/ui/activity/RichDocumentsEditorWebView.kt-RichDocumentsMobileInterface.downloadAs()method- Keys defined in companion object:
URL = "URL",TYPE = "Type",FILENAME = "filename"
Reproduction Steps
- Open a document in Collabora Online via the Nextcloud Android app
- Click "Export as PDF" (or any other export/download format)
- The download silently fails (caught by
JSONExceptioncatch block at line 148)
Expected Behavior
The file should download to the device's Downloads folder.
Proposed Fix
Update downloadAs() to handle both key naming conventions:
@JavascriptInterface
fun downloadAs(json: String?) {
try {
json ?: return
val downloadJson = JSONObject(json)
// Support both old and new key formats from Collabora Online
val urlStr = downloadJson.optString("URL", downloadJson.optString("url", ""))
if (urlStr.isEmpty()) return
val url = urlStr.toUri()
// Support both "Type" and "format" keys
val type = downloadJson.optString("Type", downloadJson.optString("format", ""))
when {
"print".equals(type, ignoreCase = true) -> printFile(url)
"slideshow".equals(type, ignoreCase = true) -> showSlideShow(url)
else -> {
val downloadFileName = downloadJson.optString("filename", fileName)
downloadFile(url, downloadFileName)
}
}
} catch (e: JSONException) {
Log_OC.e(this, "Failed to parse download json message: $e")
}
}Key changes:
- Use
optString()instead ofgetString()to avoid exceptions on missing keys - Check for both
"URL"and"url"(case-insensitive) - Check for both
"Type"and"format"(case-insensitive) - Use
ignoreCase = truefor type comparison
Environment
- Nextcloud Android app version: (check latest)
- Collabora Online (richdocuments) server app version: 8.x+
- This affects any Collabora Online version that sends
url/formatkeys instead ofURL/Type
Activity
juliusknorr commentedon May 21, 2026
I'm curious if that changed somehow or where the difference originated from.
TypeandURLare the underlying Collabora post messages (https://sdk.collaboraonline.com/docs/postmessage_api.html). Richdocuments has not changed it, so wondering if Collabora did rename those at some point?@pedropintosilva Do you have any insight there?
juliusknorr commentedon May 21, 2026
Also Collabora has
TypeandURLsince at least 5 years https://github.com/CollaboraOnline/online/blame/3d18a28e64161858e5afad729dd8c5a8881d956e/browser/src/layer/tile/CanvasTileLayer.js#L1552chrip commentedon May 21, 2026
Same bug in the iOS app nextcloud/ios#4114
alperozturk96 commentedon May 22, 2026
I can create a PR with fallback to current one with findings here if nothing else needed to investigated?
chrip commentedon May 22, 2026
@alperozturk96 Yes please, that would be great!
Just for notice, the fix was AI-generated from static code analysis. I don't have an Android device to verify the actual behavior.
alperozturk96 commentedon May 22, 2026
I created PR but I can't find export button, what am I missing?
Screen.Recording.2026-05-22.at.16.00.55.mp4
chrip commentedon May 26, 2026
@alperozturk96 Thank you for this quick fix! Have you tested it in Collabora? In the screen recording is Euro-office shown.