mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Fix connection bug with non-ASCII SSIDs in wpa_supplicant (#11089)
* Bump base includes: koreader/koreader-base#1691 koreader/koreader-base#1692 koreader/koreader-base#1689 koreader/koreader-base#1690 koreader/koreader-base#1693 * Integrate decoding of SSIDs within wpa_supplicant The UTF-8 decoding of SSIDs is specific to wpa_supplicant. In this patch, we move all of this decoding logic to the wpa_supplicant module. We expose the raw bytes of the SSID to the NetworkMgr code, and make sure to always fix bad UTF-8 before we display the SSID to the user. Within the wpa_supplicant module, we replace the call to the wpa_passphrase binary to get the PSK with a direct function call to OpenSSL. This allows us to calculate the PSK over any arbitrary bytes, including UTF-8. In the same vein, we use the hex-encoded SSID to communicate with wpa_supplicant when setting up the network to support arbitrary bytes in the SSID. Unfortunately, we also remove the tests, as there is no way to unit test local functions.
This commit is contained in:
@@ -1067,7 +1067,7 @@ function NetworkMgr:reconnectOrShowNetworkMenu(complete_callback, interactive)
|
||||
end
|
||||
UIManager:show(InfoMessage:new{
|
||||
tag = "NetworkMgr", -- for crazy KOSync purposes
|
||||
text = T(_("Connected to network %1"), BD.wrap(self.decodeSSID(ssid))),
|
||||
text = T(_("Connected to network %1"), BD.wrap(util.fixUtf8(ssid, "<EFBFBD>"))),
|
||||
timeout = 3,
|
||||
})
|
||||
else
|
||||
@@ -1119,23 +1119,6 @@ function NetworkMgr:setWirelessBackend(name, options)
|
||||
require("ui/network/"..name).init(self, options)
|
||||
end
|
||||
|
||||
function NetworkMgr.decodeSSID(text)
|
||||
local decode = function(b)
|
||||
local c = string.char(tonumber(b, 16))
|
||||
-- This is a hack that allows us to make sure that any decoded backslash
|
||||
-- does not get replaced in the step that replaces double backslashes.
|
||||
if c == "\\" then
|
||||
return "\\\\"
|
||||
else
|
||||
return c
|
||||
end
|
||||
end
|
||||
|
||||
local decoded = text:gsub("%f[\\]\\x(%x%x)", decode)
|
||||
decoded = decoded:gsub("\\\\", "\\")
|
||||
return util.fixUtf8(decoded, "<EFBFBD>")
|
||||
end
|
||||
|
||||
-- set network proxy if global variable G_defaults:readSetting("NETWORK_PROXY") is defined
|
||||
if G_defaults:readSetting("NETWORK_PROXY") then
|
||||
NetworkMgr:setHTTPProxy(G_defaults:readSetting("NETWORK_PROXY"))
|
||||
|
||||
Reference in New Issue
Block a user