Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the Uguu uploader and SICP crash on no auth #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Fix the Uguu uploader and SICP crash on no auth #25

wants to merge 1 commit into from

Conversation

handlerug
Copy link

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.

@handlerug handlerug closed this by deleting the head repository Sep 21, 2022
@handlerug handlerug reopened this Sep 21, 2022
@handlerug
Copy link
Author

The patch:

From a486cee2d38ae1c592d31057d369b41ad41c9bc1 Mon Sep 17 00:00:00 2001
From: Umar Getagazov <umar@handlerug.me>
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
+}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant