Fix Punycode not supported for domains

markdown
Thomas 1 year ago
parent 28501e7929
commit 44752cc329

@ -110,6 +110,7 @@ import org.jsoup.nodes.Element;
import java.io.File;
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.net.IDN;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -1113,7 +1114,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
.proxy(Helper.getProxy(getApplication().getApplicationContext()))
.build();
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://" + MainActivity.currentInstance + "/api/v1/")
.baseUrl("https://" + IDN.toASCII(MainActivity.currentInstance, IDN.ALLOW_UNASSIGNED) + "/api/v1/")
.addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder()))
.client(okHttpClient)
.build();

@ -25,6 +25,7 @@ import org.simpleframework.xml.Path;
import org.simpleframework.xml.Root;
import java.io.Serializable;
import java.net.IDN;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -68,7 +69,7 @@ public class Nitter implements Serializable {
.proxy(Helper.getProxy(context))
.build();
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://" + instance)
.baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED))
.addConverterFactory(SimpleXmlConverterFactory.create())
.client(okHttpClient)
.build();

@ -31,6 +31,7 @@ import androidx.preference.PreferenceManager;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import java.io.IOException;
import java.net.IDN;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
@ -265,7 +266,7 @@ public class CrossActionHelper {
.proxy(Helper.getProxy(context))
.build();
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://" + instance + "/api/v2/")
.baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) + "/api/v2/")
.addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder()))
.client(okHttpClient)
.build();

@ -37,6 +37,7 @@ import com.bumptech.glide.Glide;
import com.bumptech.glide.request.target.CustomTarget;
import com.bumptech.glide.request.transition.Transition;
import java.net.IDN;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -142,7 +143,7 @@ public class NotificationsHelper {
.proxy(Helper.getProxy(context))
.build();
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://" + instance + "/api/v1/")
.baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) + "/api/v1/")
.addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder()))
.client(okHttpClient)
.build();

@ -23,6 +23,7 @@ import android.os.Looper;
import androidx.annotation.NonNull;
import androidx.preference.PreferenceManager;
import java.net.IDN;
import java.util.concurrent.TimeUnit;
import app.fedilab.android.R;
@ -137,7 +138,7 @@ public class PushNotifications {
.proxy(Helper.getProxy(context.getApplicationContext()))
.build();
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://" + instance + "/api/v1/")
.baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) + "/api/v1/")
.addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder()))
.client(okHttpClient)
.build();

@ -29,6 +29,7 @@ import androidx.lifecycle.ViewModelStoreOwner;
import androidx.preference.PreferenceManager;
import java.io.IOException;
import java.net.IDN;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -61,7 +62,7 @@ public class TimelineHelper {
.proxy(Helper.getProxy(context))
.build();
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://" + BaseMainActivity.currentInstance + "/api/v2/")
.baseUrl("https://" + IDN.toASCII(BaseMainActivity.currentInstance, IDN.ALLOW_UNASSIGNED) + "/api/v2/")
.addConverterFactory(GsonConverterFactory.create())
.client(okHttpClient)
.build();

@ -44,6 +44,7 @@ import com.google.common.util.concurrent.ListenableFuture;
import com.google.gson.Gson;
import java.io.IOException;
import java.net.IDN;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
@ -98,7 +99,7 @@ public class ComposeWorker extends Worker {
private static MastodonStatusesService init(Context context, @NonNull String instance) {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://" + instance + "/api/v1/")
.baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) + "/api/v1/")
.addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder()))
.client(getOkHttpClient(context))
.build();

@ -37,6 +37,7 @@ import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import java.io.IOException;
import java.net.IDN;
import java.util.List;
import java.util.concurrent.TimeUnit;
@ -251,7 +252,7 @@ public class FetchHomeWorker extends Worker {
private MastodonTimelinesService init(String instance) {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://" + instance + "/api/v1/")
.baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) + "/api/v1/")
.addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder()))
.client(okHttpClient)
.build();

@ -32,6 +32,7 @@ import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import java.io.IOException;
import java.net.IDN;
import java.util.concurrent.TimeUnit;
import app.fedilab.android.R;
@ -110,7 +111,7 @@ public class ScheduleBoostWorker extends Worker {
private MastodonStatusesService init(@NonNull String instance) {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://" + instance + "/api/v1/")
.baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) + "/api/v1/")
.addConverterFactory(GsonConverterFactory.create())
.client(getOkHttpClient())
.build();

@ -24,6 +24,7 @@ import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import java.net.IDN;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.concurrent.TimeUnit;
@ -105,7 +106,7 @@ public class AccountsVM extends AndroidViewModel {
private MastodonAccountsService init(String instance) {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://" + instance + "/api/v1/")
.baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) + "/api/v1/")
.addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder()))
.client(okHttpClient)
.build();
@ -114,7 +115,7 @@ public class AccountsVM extends AndroidViewModel {
private MastodonAccountsService initv2(String instance) {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://" + instance + "/api/v2/")
.baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) + "/api/v2/")
.addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder()))
.client(okHttpClient)
.build();

@ -23,6 +23,7 @@ import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import java.net.IDN;
import java.util.List;
import java.util.concurrent.TimeUnit;
@ -64,7 +65,7 @@ public class AdminVM extends AndroidViewModel {
private MastodonAdminService init(@NonNull String instance) {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://" + instance + "/api/v1/")
.baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) + "/api/v1/")
.addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder()))
.client(okHttpClient)
.build();
@ -73,7 +74,7 @@ public class AdminVM extends AndroidViewModel {
private MastodonAdminService initv2(@NonNull String instance) {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://" + instance + "/api/v2/")
.baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) + "/api/v2/")
.addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder()))
.client(okHttpClient)
.build();

@ -23,6 +23,7 @@ import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import java.net.IDN;
import java.util.List;
import java.util.concurrent.TimeUnit;
@ -52,7 +53,7 @@ public class AnnouncementsVM extends AndroidViewModel {
private MastodonAnnouncementsService init(@NonNull String instance) {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://" + instance + "/api/v1/")
.baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) + "/api/v1/")
.addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder()))
.client(okHttpClient)
.build();

@ -26,6 +26,7 @@ import androidx.lifecycle.MutableLiveData;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.net.IDN;
import java.util.concurrent.TimeUnit;
import app.fedilab.android.mastodon.client.endpoints.MastodonAppsService;
@ -60,7 +61,7 @@ public class AppsVM extends AndroidViewModel {
private MastodonAppsService init(String instance) throws IllegalArgumentException {
Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").create();
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://" + instance + "/api/v1/")
.baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) + "/api/v1/")
.addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder()))
.client(okHttpClient)
.build();

@ -24,6 +24,7 @@ import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import java.net.IDN;
import java.util.List;
import java.util.concurrent.TimeUnit;
@ -57,7 +58,7 @@ public class FiltersVM extends AndroidViewModel {
private MastodonFiltersService initV2(String instance) {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://" + instance + "/api/v2/")
.baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) + "/api/v2/")
// .addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder()))
.addConverterFactory(GsonConverterFactory.create())
.client(okHttpClient)

@ -26,6 +26,7 @@ import androidx.lifecycle.MutableLiveData;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.net.IDN;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
@ -63,7 +64,7 @@ public class InstancesVM extends AndroidViewModel {
private MastodonInstanceService init(@NonNull String instance) {
Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").create();
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://" + instance + "/api/v1/")
.baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) + "/api/v1/")
.addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder()))
.client(okHttpClient)
.build();

@ -24,6 +24,7 @@ import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import java.net.IDN;
import java.util.concurrent.TimeUnit;
import app.fedilab.android.mastodon.client.NodeInfoService;
@ -52,7 +53,7 @@ public class NodeInfoVM extends AndroidViewModel {
private NodeInfoService init(String instance) {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://" + instance + "/")
.baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) + "/")
.addConverterFactory(GsonConverterFactory.create())
.client(okHttpClient)
.build();

@ -23,6 +23,7 @@ import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import java.net.IDN;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@ -94,7 +95,7 @@ public class NotificationsVM extends AndroidViewModel {
private MastodonNotificationsService init(@NonNull String instance) {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://" + instance + "/api/v1/")
.baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) + "/api/v1/")
.addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder()))
.client(okHttpClient)
.build();

@ -26,6 +26,7 @@ import androidx.lifecycle.MutableLiveData;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.net.IDN;
import java.util.concurrent.TimeUnit;
import app.fedilab.android.mastodon.client.endpoints.MastodonAppsService;
@ -61,7 +62,7 @@ public class OauthVM extends AndroidViewModel {
private MastodonAppsService init(@NonNull String instance) {
Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").create();
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://" + instance + "/")
.baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) + "/")
.addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder()))
.client(okHttpClient)
.build();

@ -19,6 +19,7 @@ import android.app.Application;
import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import java.net.IDN;
import java.util.concurrent.TimeUnit;
import app.fedilab.android.mastodon.client.endpoints.MastodonOembedService;
@ -42,7 +43,7 @@ public class OembedVM extends AndroidViewModel {
private MastodonOembedService init(@NonNull String instance) {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://" + instance + "/api/v1/")
.baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) + "/api/v1/")
.addConverterFactory(GsonConverterFactory.create())
.client(okHttpClient)
.build();

@ -26,6 +26,7 @@ import androidx.lifecycle.MutableLiveData;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.net.IDN;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
@ -59,7 +60,7 @@ public class SearchVM extends AndroidViewModel {
private MastodonSearchService init(@NonNull String instance) {
Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").create();
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://" + instance + "/api/v2/")
.baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) + "/api/v2/")
.addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder()))
.client(okHttpClient)
.build();

@ -25,6 +25,7 @@ import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import java.net.IDN;
import java.util.Date;
import java.util.List;
import java.util.concurrent.TimeUnit;
@ -92,7 +93,7 @@ public class StatusesVM extends AndroidViewModel {
private MastodonStatusesService init(@NonNull String instance) {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://" + instance + "/api/v1/")
.baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) + "/api/v1/")
.addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder()))
.client(getOkHttpClient())
.build();

@ -23,6 +23,7 @@ import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import java.net.IDN;
import java.util.List;
import java.util.concurrent.TimeUnit;
@ -63,7 +64,7 @@ public class TagVM extends AndroidViewModel {
private MastodonTagService init(String instance) {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://" + instance + "/api/v1/")
.baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) + "/api/v1/")
.addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder()))
.client(okHttpClient)
.build();

@ -31,6 +31,7 @@ import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.preference.PreferenceManager;
import java.net.IDN;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@ -157,7 +158,7 @@ public class TimelinesVM extends AndroidViewModel {
private MastodonTimelinesService initInstanceOnly(String instance) {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://" + instance)
.baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED))
.addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder()))
.client(okHttpClient)
.build();
@ -166,7 +167,7 @@ public class TimelinesVM extends AndroidViewModel {
private MastodonTimelinesService initInstanceXMLOnly(String instance) {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://" + instance)
.baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED))
.addConverterFactory(SimpleXmlConverterFactory.create())
.client(okHttpClient)
.build();
@ -175,7 +176,7 @@ public class TimelinesVM extends AndroidViewModel {
private MastodonTimelinesService init(String instance) {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://" + instance + "/api/v1/")
.baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) + "/api/v1/")
.addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder()))
.client(okHttpClient)
.build();

@ -20,6 +20,7 @@ import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.MutableLiveData;
import java.net.IDN;
import java.util.List;
import java.util.concurrent.TimeUnit;
@ -48,7 +49,7 @@ public class ActionsVM extends AndroidViewModel {
private PleromaAPI init(@NonNull String instance) {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://" + instance + "/api/v1/")
.baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) + "/api/v1/")
.addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder()))
.client(okHttpClient)
.build();

@ -44,6 +44,7 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.IDN;
import java.net.URL;
import java.net.URLDecoder;
import java.util.ArrayList;
@ -253,7 +254,7 @@ public class RetrofitPeertubeAPI {
.proxy(app.fedilab.android.mastodon.helper.Helper.getProxy(_context.getApplicationContext()))
.build();
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://" + instance)
.baseUrl("https://" + IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED))
.addConverterFactory(GsonConverterFactory.create())
.client(okHttpClient)
.build();

Loading…
Cancel
Save