Skip to content

Commit 26a80ef

Browse files
tarekisclemenshimmerWires77
authored
fix: allow account names with dashed in them to be imported correctly (#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 <[email protected]> Co-authored-by: Wires77 <[email protected]>
1 parent 123d8ff commit 26a80ef

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/Classes/ImportTab.lua

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,8 @@ function ImportTabClass:DownloadCharacterList()
424424
accountName = self.controls.accountName.buf:gsub("^[%s?]+", ""):gsub("[%s?]+$", ""):gsub("%s", "+")
425425
end
426426
local sessionID = #self.controls.sessionInput.buf == 32 and self.controls.sessionInput.buf or (main.gameAccounts[accountName] and main.gameAccounts[accountName].sessionID)
427-
launch:DownloadPage(realm.hostName.."character-window/get-characters?accountName="..accountName:gsub("-", "%%23"):gsub("#", "%%23").."&realm="..realm.realmCode, function(response, errMsg)
427+
accountName = ReplaceDiscriminatorSafely(accountName)
428+
launch:DownloadPage(realm.hostName.."character-window/get-characters?accountName="..accountName:gsub("#", "%%23").."&realm="..realm.realmCode, function(response, errMsg)
428429
if errMsg == "Response code: 401" then
429430
self.charImportStatus = colorCodes.NEGATIVE.."Sign-in is required."
430431
self.charImportMode = "GETSESSIONID"
@@ -468,9 +469,9 @@ function ImportTabClass:DownloadCharacterList()
468469
self.charImportMode = "GETSESSIONID"
469470
return
470471
end
471-
realAccountName = realAccountName:gsub("-", "#")
472-
self.controls.accountName:SetText(realAccountName)
472+
realAccountName = ReplaceDiscriminatorSafely(realAccountName)
473473
accountName = realAccountName
474+
self.controls.accountName:SetText(realAccountName)
474475
self.charImportStatus = "Character list successfully retrieved."
475476
self.charImportMode = "SELECTCHAR"
476477
self.lastRealm = realm.id
@@ -1138,6 +1139,10 @@ function HexToChar(x)
11381139
return string.char(tonumber(x, 16))
11391140
end
11401141

1142+
function ReplaceDiscriminatorSafely(accountName)
1143+
return accountName:gsub("(.*)[#%-]", "%1#")
1144+
end
1145+
11411146
function UrlDecode(url)
11421147
if url == nil then
11431148
return

src/Modules/Common.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -947,4 +947,4 @@ function ImportBuild(importLink, callback)
947947
-- try to decode input buffer
948948
callback(Inflate(common.base64.decode(importLink:gsub("-", "+"):gsub("_", "/"))), nil)
949949
end
950-
end
950+
end

0 commit comments

Comments
 (0)