Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply URL encode/decode changes #11330

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,8 @@ private void handleCookiesFromUrl(@Nullable final String url) {
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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -30,7 +29,6 @@

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;
Expand Down Expand Up @@ -107,28 +105,15 @@ private void updatePreferencesSummary() {

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) {
Expand Down
Loading