From 78bcfcb8768bbdfbed27eaf8fcb3daa727acde0b Mon Sep 17 00:00:00 2001 From: sewn Date: Fri, 8 Sep 2023 22:01:01 +0300 Subject: [PATCH] drop uri parsing, pass to binary directly --- cmd/vinegar/binary.go | 6 +-- roblox/bootstrapper/uri.go | 92 --------------------------------- roblox/bootstrapper/uri_test.go | 43 --------------- 3 files changed, 2 insertions(+), 139 deletions(-) delete mode 100644 roblox/bootstrapper/uri.go delete mode 100644 roblox/bootstrapper/uri_test.go diff --git a/cmd/vinegar/binary.go b/cmd/vinegar/binary.go index 5b300c9d..a2c1185e 100644 --- a/cmd/vinegar/binary.go +++ b/cmd/vinegar/binary.go @@ -96,10 +96,8 @@ func Binary(bt roblox.BinaryType, cfg *config.Config, pfx *wine.Prefix, args ... } } - if strings.HasPrefix(strings.Join(args, " "), "roblox-player:1") { - args = bootstrapper.ParsePlayerURI(args[0]) - } else if strings.HasPrefix(strings.Join(args, " "), "roblox-studio:1") { - args = append([]string{"-protocolString"}, args[0]) + if strings.HasPrefix(strings.Join(args, " "), "roblox-studio:1") { + args = []string{"-protocolString", args[0]} } if appCfg.ForcedVersion != "" { diff --git a/roblox/bootstrapper/uri.go b/roblox/bootstrapper/uri.go deleted file mode 100644 index 76d475ef..00000000 --- a/roblox/bootstrapper/uri.go +++ /dev/null @@ -1,92 +0,0 @@ -package bootstrapper - -import ( - "log" - "net/url" - "strings" -) - -var PlayerURIKeyFlags = map[string]string{ - "gameinfo": "--authenticationTicket", - "placelauncherurl": "--joinScriptUrl", - "launchtime": "--launchtime", - "browsertrackerid": "--browserTrackerId", - "robloxLocale": "--rloc", - "gameLocale": "--gloc", -} - -func ParsePlayerURI(launchURI string) (args []string) { - // Roblox Client forces usage of the desktop app - args = append(args, "--app") - - for _, param := range strings.Split(launchURI, "+") { - pair := strings.Split(param, ":") - if len(pair) != 2 { - continue - } - - key, val := pair[0], pair[1] - - if key == "channel" { - log.Printf("Roblox is attempting to set channel to %s from launch URI, ignoring", val) - - continue - } - - flag, ok := PlayerURIKeyFlags[key] - if !ok || val == "" { - continue - } - - if key == "placelauncherurl" { - urlDecoded, _ := url.QueryUnescape(val) - val = urlDecoded - } - - // arguments are given as --flag value - args = append(args, flag, val) - } - - return -} - -func ParseStudioURI(launchURI string) (args []string) { - tempArgMap := make(map[string]string, 0) - - for _, param := range strings.Split(launchURI, "+") { - pair := strings.Split(param, ":") - if len(pair) != 2 { - continue - } - - key, val := pair[0], pair[1] - - if key == "channel" { - log.Printf("Roblox is attempting to set channel to %s from launch URI, ignoring", val) - - continue - } - - if key == "gameinfo" { - args = append(args, - "-url", "https://www.roblox.com/Login/Negotiate.ashx", "-ticket", val, - ) - } else if key != "roblox-studio" { - tempArgMap[key] = val - args = append(args, "-"+key, val) - } - } - - if tempArgMap["launchmode"] != "" && tempArgMap["task"] == "" { - switch tempArgMap["launchmode"] { - case "plugin": - args = append(args, "-task", "InstallPlugin", "-pluginId", tempArgMap["pluginid"]) - case "asset": - args = append(args, "-task", "TryAsset", "-assetId", tempArgMap["pluginid"]) - case "edit": - args = append(args, "-task", "EditPlace") - } - } - - return -} diff --git a/roblox/bootstrapper/uri_test.go b/roblox/bootstrapper/uri_test.go deleted file mode 100644 index 04508837..00000000 --- a/roblox/bootstrapper/uri_test.go +++ /dev/null @@ -1,43 +0,0 @@ -package bootstrapper - -import ( - "testing" -) - -func TestPlayerURIParsed(t *testing.T) { - uri := "roblox-player:1" - uri += "+launchmode:play" - uri += "+gameinfo:token" - uri += "+launchtime:0" - uri += "+placelauncherurl:https%3A%2F%2Fassetgame.roblox.com%2Fgame%2FPlaceLauncher.ashx" - uri += "+browsertrackerid:0" - uri += "+robloxLocale:en_us" - uri += "+gameLocale:en_us" - uri += "+channel:Ganesh" - - argsWant := []string{ - "--app", - "--authenticationTicket", "token", - "--launchtime", "0", - "--joinScriptUrl", "https://assetgame.roblox.com/game/PlaceLauncher.ashx", - "--browserTrackerId", "0", - "--rloc", "en_us", - "--gloc", "en_us", - "-channel", "Ganesh", - } - args := ParsePlayerURI(uri) - - for i, val := range args { - if val != argsWant[i] { - t.Fatalf("launch player uri parsing failed, key %s, want key match for %s", val, argsWant[i]) - } - } -} - -func TestPlayerURIInvalidKey(t *testing.T) { - args := ParsePlayerURI("roblox-player:1+launchmode:play+channel") - - if len(args) == 1 && args[0] != "--app" { - t.Fail() - } -}