Skip to content

Commit

Permalink
Unescape escaped characters in ESSIDs
Browse files Browse the repository at this point in the history
This makes ESSIDs such as "Hôtel Ibn Batouta" appear
correctly in the list.
  • Loading branch information
hishamhm committed Feb 15, 2023
1 parent b3a5ff1 commit cdf14b7
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions gobo/awesome/gobonet.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ local wlan_interface
local wired_interface
local wired_connected = false

local function unescape_essid(essid)
if not essid then
return nil
end
return essid:gsub("\\x00", "")
:gsub("\\x(..)", function(sn) return string.char(tonumber("0x" .. sn)) end)
end

local function pread(cmd)
local pd = io.popen(cmd, "r")
if not pd then
Expand Down Expand Up @@ -246,7 +254,7 @@ function gobonet.new()
end
end
local iwconfig = pread("iwconfig")
local my_essid = iwconfig:match('ESSID:"([^\n]*)"%s*\n')
local my_essid = unescape_essid(iwconfig:match('ESSID:"([^\n]*)"%s*\n'))
local scan = ""
if not is_scanning() then
scan = pread("gobonet_backend quick-scan "..wlan_interface)
Expand All @@ -260,7 +268,8 @@ function gobonet.new()
end
curr_entry = { [1] = " " .. value:gsub(" ", "") }
elseif key == "ESSID" then
local essid = value:match('^"(.*)"$'):gsub("\\x00", "")
local essid = unescape_essid(value:match('^"(.*)"$'))

if essid ~= "" then
local label = " " .. essid
curr_entry[1] = label
Expand Down

0 comments on commit cdf14b7

Please sign in to comment.