From 39d31682274dd60d9fda7e55db06b7bece312101 Mon Sep 17 00:00:00 2001 From: Kavin <20838718+FireMasterK@users.noreply.github.com> Date: Mon, 20 Nov 2023 08:31:19 +0000 Subject: [PATCH] Include path in qhash --- .../java/me/kavin/piped/utils/URLUtils.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main/java/me/kavin/piped/utils/URLUtils.java b/src/main/java/me/kavin/piped/utils/URLUtils.java index 72e69d4..7a8184a 100644 --- a/src/main/java/me/kavin/piped/utils/URLUtils.java +++ b/src/main/java/me/kavin/piped/utils/URLUtils.java @@ -109,6 +109,12 @@ public class URLUtils { queryPairs.add(List.of("host", host)); } + String path = url.getPath(); + + if (path.contains("=")) { + path = StringUtils.substringBefore(path, "=") + "=" + StringUtils.substringAfter(path, "=").replace("-rj", "-rw"); + } + if (PROXY_HASH_SECRET != null) try { MessageDigest md = MessageDigest.getInstance("BLAKE3-256"); @@ -117,6 +123,8 @@ public class URLUtils { md.update(pair.get(1).getBytes(StandardCharsets.UTF_8)); } + md.update(path.getBytes(StandardCharsets.UTF_8)); + md.update(PROXY_HASH_SECRET); queryPairs.add(List.of("qhash", Hex.encodeHexString(md.digest()).substring(0, 8))); @@ -124,13 +132,6 @@ public class URLUtils { e.printStackTrace(); } - - String path = url.getPath(); - - if (path.contains("=")) { - path = StringUtils.substringBefore(path, "=") + "=" + StringUtils.substringAfter(path, "=").replace("-rj", "-rw"); - } - String newUrl = proxy + path; StringBuilder qstring = null; @@ -142,9 +143,9 @@ public class URLUtils { qstring.append("&"); } - qstring.append(pair.get(0)); + qstring.append(silentEncode(pair.get(0))); qstring.append("="); - qstring.append(pair.get(1)); + qstring.append(silentEncode(pair.get(1))); } newUrl += "?" + qstring;