Skip to content

Commit aa9f6f9

Browse files
authored
Feat: Handle non-ASCII account names better (#8949)
* Feat: Handle "non-ASCII" account names better Refactor the `pasteFilter` on the import -> account name EditControl to encode non-ASCII characters in a more URL-friendly manner than it was previously. This change eliminates the need to use `www.urlencoder.org` so I've removed that warning and the button. Tested OK with: 쁘레따뽀르떼#4360 * adjust position of missing discriminator warning * add help message
1 parent e6677c9 commit aa9f6f9

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/Classes/ImportTab.lua

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,13 @@ local ImportTabClass = newClass("ImportTab", "ControlHost", "Control", function(
4141
self.controls.accountRealm:SelByValue( main.lastRealm or "PC", "id" )
4242
self.controls.accountName = new("EditControl", {"LEFT",self.controls.accountRealm,"RIGHT"}, {8, 0, 200, 20}, main.lastAccountName or "", nil, "%c", nil, nil, nil, nil, true)
4343
self.controls.accountName.pasteFilter = function(text)
44-
return text:gsub("[\128-\255]",function(c)
45-
return codePointToUTF8(c:byte(1)):gsub(".",function(c)
46-
return string.format("%%%X", c:byte(1))
47-
end)
44+
return text:gsub(".", function(c)
45+
local byte = c:byte()
46+
if byte >= 128 then
47+
return string.format("%%%02X", byte)
48+
else
49+
return c
50+
end
4851
end)
4952
end
5053
-- accountHistory Control
@@ -92,16 +95,12 @@ local ImportTabClass = newClass("ImportTab", "ControlHost", "Control", function(
9295
tooltip:AddLine(16, "^7Removes account from the dropdown list")
9396
end
9497

95-
self.controls.accountNameUnicode = new("LabelControl", {"TOPLEFT",self.controls.accountRealm,"BOTTOMLEFT"}, {0, 34, 0, 14}, "^7Note: if the account name contains non-ASCII characters then it must be URL encoded first.")
96-
self.controls.accountNameURLEncoder = new("ButtonControl", {"TOPLEFT",self.controls.accountNameUnicode,"BOTTOMLEFT"}, {0, 4, 170, 18}, "^x4040FFhttps://www.urlencoder.org/", function()
97-
OpenURL("https://www.urlencoder.org/")
98-
end)
99-
100-
self.controls.accountNameMissingDiscriminator = new("LabelControl", {"BOTTOMLEFT",self.controls.accountNameUnicode,"TOPLEFT"}, {0, -4, 0, 18}, "^1Missing discriminator e.g. #1234")
98+
self.controls.accountNameMissingDiscriminator = new("LabelControl", {"TOPLEFT",self.controls.accountName,"BOTTOMLEFT"}, {0, 8, 0, 16}, "^1Missing discriminator e.g. #1234")
10199
self.controls.accountNameMissingDiscriminator.shown = function()
102100
return not self.controls.accountName.buf:match("[#%-]%d%d%d%d$")
103101
end
104-
102+
103+
self.controls.accountNameUnicode = new("LabelControl", {"TOPLEFT",self.controls.accountRealm,"BOTTOMLEFT"}, {0, 34, 0, 14}, "^7Note: if the account name contains non-ASCII characters it must be pasted into the textbox,\nnot typed manually.")
105104

106105
-- Stage: input POESESSID
107106
self.controls.sessionHeader = new("LabelControl", {"TOPLEFT",self.controls.sectionCharImport,"TOPLEFT"}, {6, 40, 200, 14})

0 commit comments

Comments
 (0)