Skip to content

Commit

Permalink
fix: allow account names with dashed in them to be imported correctly (
Browse files Browse the repository at this point in the history
…#8370)

* fix: allow account names with dashed in them to be imported correctly

* move ReplaceCharAtIndex to Common.lua and fix indent

* Simplify logic

---------

Co-authored-by: Clemens Himmer <clemens@himmer.software>
Co-authored-by: Wires77 <Wires77@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 22, 2024
1 parent 123d8ff commit 26a80ef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/Classes/ImportTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,8 @@ function ImportTabClass:DownloadCharacterList()
accountName = self.controls.accountName.buf:gsub("^[%s?]+", ""):gsub("[%s?]+$", ""):gsub("%s", "+")
end
local sessionID = #self.controls.sessionInput.buf == 32 and self.controls.sessionInput.buf or (main.gameAccounts[accountName] and main.gameAccounts[accountName].sessionID)
launch:DownloadPage(realm.hostName.."character-window/get-characters?accountName="..accountName:gsub("-", "%%23"):gsub("#", "%%23").."&realm="..realm.realmCode, function(response, errMsg)
accountName = ReplaceDiscriminatorSafely(accountName)
launch:DownloadPage(realm.hostName.."character-window/get-characters?accountName="..accountName:gsub("#", "%%23").."&realm="..realm.realmCode, function(response, errMsg)
if errMsg == "Response code: 401" then
self.charImportStatus = colorCodes.NEGATIVE.."Sign-in is required."
self.charImportMode = "GETSESSIONID"
Expand Down Expand Up @@ -468,9 +469,9 @@ function ImportTabClass:DownloadCharacterList()
self.charImportMode = "GETSESSIONID"
return
end
realAccountName = realAccountName:gsub("-", "#")
self.controls.accountName:SetText(realAccountName)
realAccountName = ReplaceDiscriminatorSafely(realAccountName)
accountName = realAccountName
self.controls.accountName:SetText(realAccountName)
self.charImportStatus = "Character list successfully retrieved."
self.charImportMode = "SELECTCHAR"
self.lastRealm = realm.id
Expand Down Expand Up @@ -1138,6 +1139,10 @@ function HexToChar(x)
return string.char(tonumber(x, 16))
end

function ReplaceDiscriminatorSafely(accountName)
return accountName:gsub("(.*)[#%-]", "%1#")
end

function UrlDecode(url)
if url == nil then
return
Expand Down
2 changes: 1 addition & 1 deletion src/Modules/Common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -947,4 +947,4 @@ function ImportBuild(importLink, callback)
-- try to decode input buffer
callback(Inflate(common.base64.decode(importLink:gsub("-", "+"):gsub("_", "/"))), nil)
end
end
end

0 comments on commit 26a80ef

Please sign in to comment.