mirror of
https://github.com/whyorean/AuroraStore.git
synced 2026-06-19 13:08:59 -04:00
Download directory preference check fix
Symbolic links are resolved now. ".." are resolved before checking now.
This commit is contained in:
@@ -5,6 +5,7 @@ import android.content.pm.PackageManager;
|
||||
import android.os.Environment;
|
||||
import android.preference.EditTextPreference;
|
||||
import android.preference.Preference;
|
||||
import android.util.Log;
|
||||
|
||||
import com.github.yeriomin.yalpstore.ContextUtil;
|
||||
import com.github.yeriomin.yalpstore.Paths;
|
||||
@@ -34,7 +35,12 @@ public class DownloadDirectory extends Abstract {
|
||||
if (!result) {
|
||||
ContextUtil.toast(activity, R.string.error_downloads_directory_not_writable);
|
||||
} else {
|
||||
preference.setSummary(new File(Environment.getExternalStorageDirectory(), newValue).getAbsolutePath());
|
||||
try {
|
||||
preference.setSummary(new File(Environment.getExternalStorageDirectory(), newValue).getCanonicalPath());
|
||||
} catch (IOException e) {
|
||||
Log.i(getClass().getName(), "checkNewValue returned true, but drawing the path \"" + newValue + "\" in the summary failed... strange");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -42,6 +48,9 @@ public class DownloadDirectory extends Abstract {
|
||||
private boolean checkNewValue(String newValue) {
|
||||
try {
|
||||
File newDir = new File(Environment.getExternalStorageDirectory(), newValue).getCanonicalFile();
|
||||
if (!newDir.getCanonicalPath().startsWith(Environment.getExternalStorageDirectory().getCanonicalPath())) {
|
||||
return false;
|
||||
}
|
||||
if (newDir.exists()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user