aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoman / Linnea Gräf <roman.graef@gmail.com>2023-02-04 14:39:11 +0100
committerGitHub <noreply@github.com>2023-02-04 14:39:11 +0100
commit2cdedc4e5db57564d05c50230c52e8e887d2d8b5 (patch)
tree1badb0bb9bcd6caf504000abc7def79222775fdc /src
parente9a07b41c5124a357ea1231af04f2a6b3c2daffa (diff)
downloadNotEnoughUpdates-2cdedc4e5db57564d05c50230c52e8e887d2d8b5.tar.gz
NotEnoughUpdates-2cdedc4e5db57564d05c50230c52e8e887d2d8b5.tar.bz2
NotEnoughUpdates-2cdedc4e5db57564d05c50230c52e8e887d2d8b5.zip
Restrict texture https upgrading to only minecraft.net (#578)
Diffstat (limited to 'src')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/hooks/ThreadDownloadImageHook.java17
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinThreadDownloadImageData.java17
2 files changed, 27 insertions, 7 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/hooks/ThreadDownloadImageHook.java b/src/main/java/io/github/moulberry/notenoughupdates/hooks/ThreadDownloadImageHook.java
index 4fa57360..e84fce11 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/hooks/ThreadDownloadImageHook.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/hooks/ThreadDownloadImageHook.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2022 Linnea Gräf
+ * Copyright (C) 2022-2023 Linnea Gräf
*
* This file is part of NotEnoughUpdates.
*
@@ -26,15 +26,22 @@ import javax.net.ssl.HttpsURLConnection;
import java.net.HttpURLConnection;
public class ThreadDownloadImageHook {
+ public static String hookThreadImageLink(String originalLink) {
+ if (!NotEnoughUpdates.INSTANCE.config.misc.fixSteveSkulls || originalLink == null || !originalLink.startsWith(
+ "http://textures.minecraft.net"))
+ return originalLink;
+ return originalLink.replace("http://", "https://");
+ }
+
public static void hookThreadImageConnection(HttpURLConnection connection) {
if ((connection instanceof HttpsURLConnection) && NotEnoughUpdates.INSTANCE.config.misc.fixSteveSkulls) {
ApiUtil.patchHttpsRequest((HttpsURLConnection) connection);
}
}
- public static String hookThreadImageLink(String originalLink) {
- if (!NotEnoughUpdates.INSTANCE.config.misc.fixSteveSkulls || originalLink == null)
- return originalLink;
- return originalLink.replace("http://", "https://");
+ public interface AccessorThreadDownloadImageData {
+ String getOriginalUrl();
+
+ String getPatchedUrl();
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinThreadDownloadImageData.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinThreadDownloadImageData.java
index c6d25a9e..fd4ee495 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinThreadDownloadImageData.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinThreadDownloadImageData.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2022 Linnea Gräf
+ * Copyright (C) 2022-2023 Linnea Gräf
*
* This file is part of NotEnoughUpdates.
*
@@ -30,12 +30,14 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(ThreadDownloadImageData.class)
-public class MixinThreadDownloadImageData {
+public class MixinThreadDownloadImageData implements ThreadDownloadImageHook.AccessorThreadDownloadImageData{
@Mutable
@Shadow
@Final
private String imageUrl;
+ private String originalUrl;
+
@Redirect(
method = "<init>",
at = @At(
@@ -44,5 +46,16 @@ public class MixinThreadDownloadImageData {
opcode = Opcodes.PUTFIELD))
public void useHttpsDownloadLinks(ThreadDownloadImageData instance, String value) {
this.imageUrl = ThreadDownloadImageHook.hookThreadImageLink(value);
+ this.originalUrl = value;
+ }
+
+ @Override
+ public String getOriginalUrl() {
+ return originalUrl;
+ }
+
+ @Override
+ public String getPatchedUrl() {
+ return imageUrl;
}
}