Skip to content
Snippets Groups Projects
Commit 704dcd02 authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Correctly match additional URIs.

parent f4801576
No related branches found
No related tags found
No related merge requests found
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- Enable after we target Android P -->
<!--<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />-->
<application <application
android:name=".QuasseldroidNG" android:name=".QuasseldroidNG"
......
...@@ -5,6 +5,7 @@ import android.content.pm.ShortcutInfo ...@@ -5,6 +5,7 @@ import android.content.pm.ShortcutInfo
import android.content.pm.ShortcutManager import android.content.pm.ShortcutManager
import android.graphics.drawable.Icon import android.graphics.drawable.Icon
import android.os.Build import android.os.Build
import android.os.StrictMode
import android.support.v7.preference.PreferenceManager import android.support.v7.preference.PreferenceManager
import com.squareup.leakcanary.LeakCanary import com.squareup.leakcanary.LeakCanary
import de.kuschku.malheur.CrashHandler import de.kuschku.malheur.CrashHandler
...@@ -64,5 +65,52 @@ class QuasseldroidNG : Application() { ...@@ -64,5 +65,52 @@ class QuasseldroidNG : Application() {
.build() .build()
) )
} }
if (BuildConfig.DEBUG) {
StrictMode.setThreadPolicy(
StrictMode.ThreadPolicy.Builder()
.detectNetwork()
.detectCustomSlowCalls()
.let {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
it.detectResourceMismatches()
} else {
it
}
}
.let {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
it.detectUnbufferedIo()
} else {
it
}
}
.penaltyLog()
.build()
)
StrictMode.setVmPolicy(
StrictMode.VmPolicy.Builder()
.detectLeakedSqlLiteObjects()
.detectActivityLeaks()
.detectLeakedClosableObjects()
.detectLeakedRegistrationObjects()
.let {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
it.detectFileUriExposure()
} else {
it
}
}
.let {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
it.detectContentUriWithoutPermission()
} else {
it
}
}
.penaltyLog()
.build()
)
}
} }
} }
...@@ -297,14 +297,14 @@ class QuasselMessageRenderer( ...@@ -297,14 +297,14 @@ class QuasselMessageRenderer(
@Language("RegExp") @Language("RegExp")
private val scheme = "(?:(?:mailto:|magnet:|(?:[+.-]?\\w)+://)|www(?=\\.\\S+\\.))" private val scheme = "(?:(?:mailto:|magnet:|(?:[+.-]?\\w)+://)|www(?=\\.\\S+\\.))"
@Language("RegExp") @Language("RegExp")
private val authority = "(?:(?:[,.;@:]?[-\\w]+)+\\.?|\\[[0-9a-f:.]+])(?::\\d+)?" private val authority = "(?:(?:[,.;@:]?[-\\w]+)+\\.?|\\[[0-9a-f:.]+])?(?::\\d+)?"
@Language("RegExp") @Language("RegExp")
private val urlChars = "(?:[,.;:]*[\\w~@/?&=+$()!%#*-])" private val urlChars = "(?:[,.;:]*[\\w~@/?&=+$()!%#*-])"
@Language("RegExp") @Language("RegExp")
private val urlEnd = "((?:>|[,.;:\"]*\\s|\\b|$))" private val urlEnd = "((?:>|[,.;:\"]*\\s|\\b|$))"
private val urlPattern = Regex( private val urlPattern = Regex(
"\\b($scheme$authority(?:/$urlChars*)?)$urlEnd", "\\b($scheme$authority(?:$urlChars*)?)$urlEnd",
RegexOption.IGNORE_CASE RegexOption.IGNORE_CASE
) )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment