1
0
mirror of https://github.com/TeamNewPipe/NewPipe.git synced 2024-11-21 10:32:33 +01:00

Merge pull request #11330 from Isira-Seneviratne/Java-10-URL-NP

Apply URL encode/decode changes
This commit is contained in:
Profpatsch 2024-11-19 14:05:04 +01:00 committed by GitHub
commit ffcba175ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 24 deletions

View File

@ -185,10 +185,8 @@ public class ReCaptchaActivity extends AppCompatActivity {
final int abuseEnd = url.indexOf("+path");
try {
String abuseCookie = url.substring(abuseStart + 13, abuseEnd);
abuseCookie = Utils.decodeUrlUtf8(abuseCookie);
handleCookies(abuseCookie);
} catch (IllegalArgumentException | StringIndexOutOfBoundsException e) {
handleCookies(Utils.decodeUrlUtf8(url.substring(abuseStart + 13, abuseEnd)));
} catch (final StringIndexOutOfBoundsException e) {
if (MainActivity.DEBUG) {
Log.e(TAG, "handleCookiesFromUrl: invalid google abuse starting at "
+ abuseStart + " and ending at " + abuseEnd + " for url " + url, e);

View File

@ -1,6 +1,5 @@
package org.schabi.newpipe.settings;
import static org.schabi.newpipe.extractor.utils.Utils.decodeUrlUtf8;
import static org.schabi.newpipe.util.Localization.assureCorrectAppLanguage;
import android.app.Activity;
@ -30,7 +29,6 @@ import org.schabi.newpipe.util.FilePickerActivityHelper;
import java.io.File;
import java.io.IOException;
import java.net.URI;
public class DownloadSettingsFragment extends BasePreferenceFragment {
public static final boolean IGNORE_RELEASE_ON_OLD_PATH = true;
@ -107,28 +105,15 @@ public class DownloadSettingsFragment extends BasePreferenceFragment {
private void showPathInSummary(final String prefKey, @StringRes final int defaultString,
final Preference target) {
String rawUri = defaultPreferences.getString(prefKey, null);
if (rawUri == null || rawUri.isEmpty()) {
final Uri uri = Uri.parse(defaultPreferences.getString(prefKey, ""));
if (uri.equals(Uri.EMPTY)) {
target.setSummary(getString(defaultString));
return;
}
if (rawUri.charAt(0) == File.separatorChar) {
target.setSummary(rawUri);
return;
}
if (rawUri.startsWith(ContentResolver.SCHEME_FILE)) {
target.setSummary(new File(URI.create(rawUri)).getPath());
return;
}
try {
rawUri = decodeUrlUtf8(rawUri);
} catch (final IllegalArgumentException e) {
// nothing to do
}
target.setSummary(rawUri);
final String summary = ContentResolver.SCHEME_FILE.equals(uri.getScheme())
? uri.getPath() : uri.toString();
target.setSummary(summary);
}
private boolean isFileUri(final String path) {