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 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- Enable after we target Android P -->
<!--<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />-->
<application
android:name=".QuasseldroidNG"
......
......@@ -5,6 +5,7 @@ import android.content.pm.ShortcutInfo
import android.content.pm.ShortcutManager
import android.graphics.drawable.Icon
import android.os.Build
import android.os.StrictMode
import android.support.v7.preference.PreferenceManager
import com.squareup.leakcanary.LeakCanary
import de.kuschku.malheur.CrashHandler
......@@ -64,5 +65,52 @@ class QuasseldroidNG : Application() {
.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(
@Language("RegExp")
private val scheme = "(?:(?:mailto:|magnet:|(?:[+.-]?\\w)+://)|www(?=\\.\\S+\\.))"
@Language("RegExp")
private val authority = "(?:(?:[,.;@:]?[-\\w]+)+\\.?|\\[[0-9a-f:.]+])(?::\\d+)?"
private val authority = "(?:(?:[,.;@:]?[-\\w]+)+\\.?|\\[[0-9a-f:.]+])?(?::\\d+)?"
@Language("RegExp")
private val urlChars = "(?:[,.;:]*[\\w~@/?&=+$()!%#*-])"
@Language("RegExp")
private val urlEnd = "((?:>|[,.;:\"]*\\s|\\b|$))"
private val urlPattern = Regex(
"\\b($scheme$authority(?:/$urlChars*)?)$urlEnd",
"\\b($scheme$authority(?:$urlChars*)?)$urlEnd",
RegexOption.IGNORE_CASE
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment