diff --git a/src/Classes/ImportTab.lua b/src/Classes/ImportTab.lua index ac783a44be..f7f86967f0 100644 --- a/src/Classes/ImportTab.lua +++ b/src/Classes/ImportTab.lua @@ -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" @@ -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 @@ -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 diff --git a/src/Modules/Common.lua b/src/Modules/Common.lua index 270e653d95..679b3d8ce1 100644 --- a/src/Modules/Common.lua +++ b/src/Modules/Common.lua @@ -947,4 +947,4 @@ function ImportBuild(importLink, callback) -- try to decode input buffer callback(Inflate(common.base64.decode(importLink:gsub("-", "+"):gsub("_", "/"))), nil) end -end \ No newline at end of file +end