mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-07 20:31:02 -05:00
Prevent invalid user agent header values from being set
This commit is contained in:
parent
2921be620a
commit
d2e62ffb19
2 changed files with 9 additions and 0 deletions
|
@ -61,6 +61,7 @@ import eu.kanade.tachiyomi.util.system.setDefaultSettings
|
|||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import kotlinx.coroutines.launch
|
||||
import logcat.LogPriority
|
||||
import okhttp3.Headers
|
||||
import rikka.sui.Sui
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
@ -267,6 +268,13 @@ class SettingsAdvancedScreen : SearchableSettings {
|
|||
context.toast(R.string.error_user_agent_string_blank)
|
||||
return@EditTextPreference false
|
||||
}
|
||||
try {
|
||||
// OkHttp checks for valid values internally
|
||||
Headers.Builder().add("User-Agent", it)
|
||||
} catch (_: IllegalArgumentException) {
|
||||
context.toast(R.string.error_user_agent_string_invalid)
|
||||
return@EditTextPreference false
|
||||
}
|
||||
context.toast(R.string.requires_app_restart)
|
||||
true
|
||||
},
|
||||
|
|
|
@ -498,6 +498,7 @@
|
|||
<string name="pref_dns_over_https">DNS over HTTPS (DoH)</string>
|
||||
<string name="pref_user_agent_string">Default user agent string</string>
|
||||
<string name="error_user_agent_string_blank">User agent string can not be blank</string>
|
||||
<string name="error_user_agent_string_invalid">Invalid user agent string</string>
|
||||
<string name="pref_reset_user_agent_string">Reset default user agent string</string>
|
||||
<string name="requires_app_restart">Requires app restart to take effect</string>
|
||||
<string name="cookies_cleared">Cookies cleared</string>
|
||||
|
|
Loading…
Reference in a new issue