Pomfshare
Pomfshare copied to clipboard
Fix the Uguu uploader and SICP crash on no auth
Note: I have no idea whether Host.Type.POMF and Host.Type.UGUU should really be called after pomf and uguu; I'm too late to the pomf.se party to know who was the first or what was the standard back then. However, pomf.cat and uguu.se seem to be based on a single codebase (and both use files[] not file), while sicp.me is different (uses file). So maybe the enum constants should be renamed.
Also, in uguu.se gyazo and text response types are synonyms, but I put gyazo in to be consistent with the pomf.cat definition.
Also, it seems like hostings supported don't exhibit the weird behavior described in the extractUrl function, so maybe it should be ditched altogether.
The patch:
From a486cee2d38ae1c592d31057d369b41ad41c9bc1 Mon Sep 17 00:00:00 2001
From: Umar Getagazov <[email protected]>
Date: Sun, 17 Jul 2022 15:01:28 +0300
Subject: [PATCH] Fix the Uguu uploader and SICP crash on no auth
---
.../science/itaintrocket/pomfshare/HostListActivity.kt | 4 ++--
.../main/kotlin/science/itaintrocket/pomfshare/Uploader.kt | 5 ++++-
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/app/src/main/kotlin/science/itaintrocket/pomfshare/HostListActivity.kt b/app/src/main/kotlin/science/itaintrocket/pomfshare/HostListActivity.kt
index 666b0d4..d937183 100644
--- a/app/src/main/kotlin/science/itaintrocket/pomfshare/HostListActivity.kt
+++ b/app/src/main/kotlin/science/itaintrocket/pomfshare/HostListActivity.kt
@@ -27,7 +27,7 @@ class HostListActivity() : FragmentActivity(), RequestAuthenticationDialog.Reque
// This should probably be stored in a proper format at some point, but cba now
hosts.add(Host("Pomf.cat", "https://pomf.cat/upload.php?output=gyazo", "75MiB", Host.Type.POMF))
hosts.add(Host("SICP", "https://sicp.me/", "25MiB", Host.Type.UGUU, authRequired = true))
- hosts.add(Host("Uguu", "https://uguu.se/api.php?d=upload-tool", "100MiB, 24 hours", Host.Type.UGUU))
+ hosts.add(Host("Uguu", "https://uguu.se/upload.php?output=gyazo", "128MiB, 48 hours", Host.Type.POMF))
// If authentication data exists for a host, load it
loadHostAuthentications()
@@ -73,4 +73,4 @@ class HostListActivity() : FragmentActivity(), RequestAuthenticationDialog.Reque
}
}
-}
\ No newline at end of file
+}
diff --git a/app/src/main/kotlin/science/itaintrocket/pomfshare/Uploader.kt b/app/src/main/kotlin/science/itaintrocket/pomfshare/Uploader.kt
index eb4bd29..4c82f88 100644
--- a/app/src/main/kotlin/science/itaintrocket/pomfshare/Uploader.kt
+++ b/app/src/main/kotlin/science/itaintrocket/pomfshare/Uploader.kt
@@ -47,6 +47,9 @@ class Uploader(private val source: MainActivity, private val contentUri: Uri, pr
// domain in the result, e.g. https://example.com/https://example.com/file.jpg
// This method extracts the correct url from such a result
private fun extractUrl(result: String): String {
+ if (!result.contains(':')) {
+ return result
+ }
val protocol = result.substring(0, result.indexOf(':')) // http or https?
val index = result.lastIndexOf("$protocol://")
return if (index > 0) {
@@ -69,4 +72,4 @@ class Uploader(private val source: MainActivity, private val contentUri: Uri, pr
source.finishUpload(result)
}
-}
\ No newline at end of file
+}