mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-04-20 03:24:50 +00:00
SLD checks, minor fixes
This commit is contained in:
parent
72efb21439
commit
7439e44e44
5 changed files with 45 additions and 10 deletions
File diff suppressed because one or more lines are too long
|
@ -4,6 +4,7 @@ import android.net.Uri
|
|||
import com.futo.platformplayer.SignatureProvider
|
||||
import com.futo.platformplayer.api.media.Serializer
|
||||
import com.futo.platformplayer.engine.IV8PluginConfig
|
||||
import com.futo.platformplayer.matchesDomain
|
||||
import com.futo.platformplayer.states.StatePlugins
|
||||
import kotlinx.serialization.Contextual
|
||||
import java.net.URL
|
||||
|
@ -79,7 +80,7 @@ class SourcePluginConfig(
|
|||
private val _allowUrlsLower: List<String> get() {
|
||||
if(_allowUrlsLowerVal == null)
|
||||
_allowUrlsLowerVal = allowUrls.map { it.lowercase() }
|
||||
.filter { it.length > 0 && (it[0] != '*' || (_allowRegex.matches(it))) };
|
||||
.filter { it.length > 0 };
|
||||
return _allowUrlsLowerVal!!;
|
||||
};
|
||||
|
||||
|
@ -172,12 +173,10 @@ class SourcePluginConfig(
|
|||
return true;
|
||||
val uri = Uri.parse(url);
|
||||
val host = uri.host?.lowercase() ?: "";
|
||||
return _allowUrlsLower.any { it == host || (it.length > 0 && it[0] == '*' && host.endsWith(it.substring(1))) };
|
||||
return _allowUrlsLower.any { it == host || (it.length > 0 && it[0] == '.' && host.matchesDomain(it)) };
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val _allowRegex = Regex("\\*\\.[a-z0-9]+\\.[a-z]+");
|
||||
|
||||
fun fromJson(json: String, sourceUrl: String? = null): SourcePluginConfig {
|
||||
val obj = Serializer.json.decodeFromString<SourcePluginConfig>(json);
|
||||
if(obj.sourceUrl == null)
|
||||
|
|
|
@ -6,6 +6,8 @@ import com.caoccao.javet.exceptions.JavetException
|
|||
import com.caoccao.javet.exceptions.JavetExecutionException
|
||||
import com.caoccao.javet.interop.V8Host
|
||||
import com.caoccao.javet.interop.V8Runtime
|
||||
import com.caoccao.javet.interop.options.V8Flags
|
||||
import com.caoccao.javet.interop.options.V8RuntimeOptions
|
||||
import com.caoccao.javet.values.V8Value
|
||||
import com.caoccao.javet.values.primitive.V8ValueBoolean
|
||||
import com.caoccao.javet.values.primitive.V8ValueInteger
|
||||
|
@ -133,9 +135,10 @@ class V8Plugin {
|
|||
synchronized(_runtimeLock) {
|
||||
if (_runtime != null)
|
||||
return;
|
||||
|
||||
//V8RuntimeOptions.V8_FLAGS.setUseStrict(true);
|
||||
val host = V8Host.getV8Instance();
|
||||
val options = host.jsRuntimeType.getRuntimeOptions();
|
||||
|
||||
_runtime = host.createV8Runtime(options);
|
||||
if (!host.isIsolateCreated)
|
||||
throw IllegalStateException("Isolate not created");
|
||||
|
|
|
@ -1674,7 +1674,7 @@ class VideoDetailView : ConstraintLayout {
|
|||
_didTriggerDatasourceErrroCount++;
|
||||
|
||||
UIDialogs.toast("Block detected, attempting bypass");
|
||||
|
||||
//return;
|
||||
fragment.lifecycleScope.launch(Dispatchers.IO) {
|
||||
val newDetails = StatePlatform.instance.getContentDetails(currentVideo.url, true).await();
|
||||
val previousVideoSource = _lastVideoSource;
|
||||
|
@ -1808,7 +1808,7 @@ class VideoDetailView : ConstraintLayout {
|
|||
}
|
||||
}
|
||||
|
||||
val doDedup = false;
|
||||
val doDedup = true;
|
||||
|
||||
val bestVideoSources = if(doDedup) (videoSources?.map { it.height * it.width }
|
||||
?.distinct()
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package com.futo.platformplayer
|
||||
|
||||
import com.futo.platformplayer.api.media.platforms.js.SourcePluginConfig
|
||||
import junit.framework.TestCase.assertEquals
|
||||
import junit.framework.TestCase.assertFalse
|
||||
import junit.framework.TestCase.assertTrue
|
||||
import org.junit.Assert.assertThrows
|
||||
import org.junit.Test
|
||||
|
@ -52,4 +54,21 @@ class UtilityTests {
|
|||
assertEquals("\ud83d\udc80\ud83d\udd14", "\\ud83d\\udc80\\ud83d\\udd14".decodeUnicode())
|
||||
assertEquals("String with a slash (/) in it", "String with a slash (/) in it".decodeUnicode())
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
fun testMatchDomain() {
|
||||
//TLD
|
||||
assertTrue("test.abc.com".matchesDomain(".abc.com"))
|
||||
assertTrue("abc.com".matchesDomain("abc.com"))
|
||||
assertFalse("test.abc.com".matchesDomain("abc.com"))
|
||||
assertThrows(IllegalStateException::class.java, { "test.uk".matchesDomain(".uk") });
|
||||
|
||||
|
||||
//SLD
|
||||
assertTrue("abc.co.uk".matchesDomain("abc.co.uk"))
|
||||
assertTrue("test.abc.co.uk".matchesDomain("test.abc.co.uk"))
|
||||
assertTrue("test.abc.co.uk".matchesDomain(".abc.co.uk"))
|
||||
assertThrows(IllegalStateException::class.java, { "test.abc.co.uk".matchesDomain(".co.uk") });
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue