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

Fix: github source checking #2548

Merged
merged 1 commit into from
Sep 20, 2024
Merged
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
@@ -1,7 +1,5 @@
package at.hannibal2.skyhanni.tweaker;

import at.hannibal2.skyhanni.SkyHanniMod;

import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
Expand All @@ -16,7 +14,8 @@

public class DownloadSourceChecker {

private static final String GITHUB_REPO_TEXT = "repo_id=511310721";
private static final String GITHUB_REPO = "511310721";
private static final String GITHUB_REPO_TEXT = "repo_id=" + GITHUB_REPO;
private static final String MODRINTH_URL = "/data/byNkmv5G/";
private static final String THE_PASSWORD = "danger";

Expand Down Expand Up @@ -96,11 +95,12 @@ private static void openMenu(URI host) {
}
));

String version = SkyHanniMod.Companion.getVersion();
// TODO FIX THIS CAUSING CLASS LOADING AND CRASHING
//String version = SkyHanniMod.Companion.getVersion();
JOptionPane.showOptionDialog(
frame,
String.format(String.join("\n", SECURITY_POPUP), uriToSimpleString(host)),
"SkyHanni " + version + " Security Error",
"SkyHanni Security Error",
JOptionPane.DEFAULT_OPTION,
JOptionPane.ERROR_MESSAGE,
null,
Expand All @@ -124,8 +124,12 @@ private static URI getDangerousHost() {
URI host = getHost(file);
if (host == null) return null;

if (host.getHost().equals("objects.githubusercontent.com") && host.getQuery().contains(GITHUB_REPO_TEXT)) {
return null;
if (host.getHost().equals("objects.githubusercontent.com")) {
if (host.getQuery().contains(GITHUB_REPO_TEXT)) {
return null;
} else if (host.getPath().contains("/" + GITHUB_REPO + "/")) {
return null;
}
} else if (host.getHost().equals("cdn.modrinth.com") && host.getPath().startsWith(MODRINTH_URL)) {
return null;
}
Expand Down
Loading