From fcd18a0072e678032ed6adca691802e71603c5b9 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Tue, 28 Jul 2026 10:01:16 +0200 Subject: [PATCH] Fail the upload when the converter returns no document use.opendocument.app answers a converted document with a redirect to it, and doOnlineConvert read the Location header without checking it was there. When the server refuses the file it answers without one, getHeaderField returns null, and the null went straight into the string concatenation - so the loader reported success for the uri "https://use.opendocument.appnull/". The user got a webview DNS error page instead of the "could not open" dialog, and the log a net::ERR_NAME_NOT_RESOLVED that says nothing about what actually went wrong. Treat a missing Location the way doTransferUpload already treats an empty body: throw, with the response code and the error body in the message, so loadSync reports the error and the offer to reopen comes back. Found by opening a truncated .odt whose central directory offset points past the entries: the core rejects it as "not a zip file" and the converter, given the same file, refuses it too. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01UgPw1bJBn1sfdw4LuL5dkW --- .../app/opendocument/droid/background/OnlineLoader.kt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/src/main/java/app/opendocument/droid/background/OnlineLoader.kt b/app/src/main/java/app/opendocument/droid/background/OnlineLoader.kt index 3e534f1a6797..7ff1c6ac46b1 100644 --- a/app/src/main/java/app/opendocument/droid/background/OnlineLoader.kt +++ b/app/src/main/java/app/opendocument/droid/background/OnlineLoader.kt @@ -98,7 +98,16 @@ class OnlineLoader(context: Context?, private val coreLoader: CoreLoader) : } } + // a converted document is answered with a redirect to it, so a response without a Location + // is the server refusing the file - concatenating the missing header would build a + // "...appnull" url that only fails later, inside the webview + val responseCode = connection.responseCode val redirectUrl = connection.getHeaderField("Location") + if (redirectUrl.isNullOrEmpty()) { + val error = readError(connection) + throw IOException("server couldn't handle request: $responseCode $error") + } + return Uri.parse(basePath + redirectUrl) }