Skip to content

Commit 190b4f9

Browse files
committed
fix HotsplotsAuth
1 parent d3b82e5 commit 190b4f9

File tree

1 file changed

+6
-4
lines changed
  • liberator/src/main/kotlin/de/binarynoise/liberator/portals

1 file changed

+6
-4
lines changed

liberator/src/main/kotlin/de/binarynoise/liberator/portals/Hotsplots.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ import de.binarynoise.util.okhttp.hasInput
88
import de.binarynoise.util.okhttp.parseHtml
99
import de.binarynoise.util.okhttp.postForm
1010
import de.binarynoise.util.okhttp.requestUrl
11+
import de.binarynoise.util.okhttp.toParameterMap
1112
import okhttp3.Cookie
1213
import okhttp3.OkHttpClient
1314
import okhttp3.Response
15+
import org.jsoup.nodes.FormElement
1416

1517
@SSID("WIFI@DB")
1618
@Suppress("SpellCheckingInspection", "GrazieInspection", "LocalVariableName", "RedundantSuppression")
@@ -55,10 +57,10 @@ object HotsplotsAuth : PortalLiberator {
5557
override fun solve(client: OkHttpClient, response: Response, cookies: Set<Cookie>) {
5658
val html1 = response.parseHtml()
5759

58-
val login_status_form = html1.getElementById("login_status_form") ?: error("no login_status_form")
59-
val inputs = login_status_form.children()
60-
.associate { element -> element.attr("name") to element.attr("value") }
61-
.filter { (name, _) -> name.isNotBlank() }
60+
val login_status_form = html1.getElementsByAttributeValue("name", "login_status_form").singleOrNull()
61+
?: error("no login_status_form")
62+
login_status_form as? FormElement ?: error("login_status_form is not a form")
63+
val inputs = login_status_form.toParameterMap()
6264
check(inputs.isNotEmpty()) { "no inputs" }
6365

6466
client.postForm(

0 commit comments

Comments
 (0)