From 087ab547c123e90eb4207bfe9080486d54fbf3ef Mon Sep 17 00:00:00 2001 From: Fabian Henneke Date: Fri, 14 Aug 2020 09:57:16 +0200 Subject: Reland symlink support (#1020) * Add symlink support to JGit (#1016) * Add symlink support to JGit * Fix a typo Co-authored-by: Harsh Shandilya * Prevent crash when following a broken symlink Co-authored-by: Harsh Shandilya --- app/build.gradle.kts | 2 ++ app/src/main/java/com/zeapo/pwdstore/crypto/DecryptActivity.kt | 10 +++++++++- app/src/main/res/values/strings.xml | 1 + buildSrc/src/main/java/Dependencies.kt | 1 + 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 257a77fe..618190d1 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -118,6 +118,8 @@ dependencies { implementation(Dependencies.ThirdParty.jgit) { exclude(group = "org.apache.httpcomponents", module = "httpclient") } + // Loaded dynamically by JGit to provide symlink support + implementation(Dependencies.ThirdParty.jgit_java7) implementation(Dependencies.ThirdParty.jsch) implementation(Dependencies.ThirdParty.sshj) implementation(Dependencies.ThirdParty.bouncycastle) diff --git a/app/src/main/java/com/zeapo/pwdstore/crypto/DecryptActivity.kt b/app/src/main/java/com/zeapo/pwdstore/crypto/DecryptActivity.kt index 79f9e6da..a697f2ba 100644 --- a/app/src/main/java/com/zeapo/pwdstore/crypto/DecryptActivity.kt +++ b/app/src/main/java/com/zeapo/pwdstore/crypto/DecryptActivity.kt @@ -12,6 +12,7 @@ import android.text.method.PasswordTransformationMethod import android.view.Menu import android.view.MenuItem import android.view.View +import android.widget.Toast import androidx.activity.result.IntentSenderRequest import androidx.activity.result.contract.ActivityResultContracts.StartIntentSenderForResult import androidx.lifecycle.lifecycleScope @@ -23,6 +24,7 @@ import com.zeapo.pwdstore.utils.PreferenceKeys import com.zeapo.pwdstore.utils.viewBinding import java.io.ByteArrayOutputStream import java.io.File +import java.io.FileNotFoundException import kotlin.time.ExperimentalTime import kotlin.time.seconds import kotlinx.coroutines.Dispatchers @@ -135,7 +137,13 @@ class DecryptActivity : BasePgpActivity(), OpenPgpServiceConnection.OnBound { val data = receivedIntent ?: Intent() data.action = OpenPgpApi.ACTION_DECRYPT_VERIFY - val inputStream = File(fullPath).inputStream() + val inputStream = try { + File(fullPath).inputStream() + } catch (e: FileNotFoundException) { + Toast.makeText(this, getString(R.string.error_broken_symlink), Toast.LENGTH_SHORT).show() + finish() + return + } val outputStream = ByteArrayOutputStream() lifecycleScope.launch(Dispatchers.IO) { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index df57f84e..98b4a0fd 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -224,6 +224,7 @@ No external repository selected Send password as plaintext using… App icon + File not found, likely because of a broken symlink Phishing-resistant search diff --git a/buildSrc/src/main/java/Dependencies.kt b/buildSrc/src/main/java/Dependencies.kt index 08e4eae2..f8432a7d 100644 --- a/buildSrc/src/main/java/Dependencies.kt +++ b/buildSrc/src/main/java/Dependencies.kt @@ -53,6 +53,7 @@ object Dependencies { const val fastscroll = "me.zhanghai.android.fastscroll:library:1.1.4" const val jsch = "com.jcraft:jsch:0.1.55" const val jgit = "org.eclipse.jgit:org.eclipse.jgit:3.7.1.201504261725-r" + const val jgit_java7 = "org.eclipse.jgit:org.eclipse.jgit.java7:3.7.1.201504261725-r" const val leakcanary = "com.squareup.leakcanary:leakcanary-android:2.4" const val plumber = "com.squareup.leakcanary:plumber-android:2.4" const val sshj = "com.hierynomus:sshj:0.29.0" -- cgit v1.2.3