From 3c23e1c79c56f7f84017c917d7a46bbafae8c68c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Dom=C3=ADnguez?= Date: Tue, 8 Aug 2017 08:15:52 +0200 Subject: [PATCH 1/2] Escape special chars on xml file name --- src/win32.coffee | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/win32.coffee b/src/win32.coffee index a5ea5b3..4e677d4 100644 --- a/src/win32.coffee +++ b/src/win32.coffee @@ -9,6 +9,12 @@ connectionStateMap = disconnected: "disconnected" # Win32 & Linux associating: "connecting" # Win32 +# +# urlify: Removes special chars from the given string +# +urlify = (a) -> + a.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '-').replace /^-+|-+$/g, '' + # # win32WirelessProfileBuilder: This method generates the Windows wireless profile # XML file corresponding to the ssid, security, and @@ -182,7 +188,7 @@ module.exports = # (3) Write xmlContent to XML wireless profile file. # try - fs.writeFileSync "#{_ap.ssid}.xml", xmlContent + fs.writeFileSync urlify(_ap.ssid) + ".xml", xmlContent catch error _msg = "Encountered an error connecting to AP: #{error}" @WiFiLog _msg, true @@ -195,7 +201,7 @@ module.exports = # (4) Load new XML profile, and connect to SSID. # COMMANDS = - loadProfile: "netsh #{@WiFiControlSettings.iface} add profile filename=\"#{_ap.ssid}.xml\"" + loadProfile: "netsh #{@WiFiControlSettings.iface} add profile filename=\"" + urlify(_ap.ssid) + ".xml\"" connect: "netsh #{@WiFiControlSettings.iface} connect ssid=\"#{_ap.ssid}\" name=\"#{_ap.ssid}\"" connectToAPChain = [ "loadProfile", "connect" ] From ac35387cb714e9f29848be52e6133517c864acf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Dom=C3=ADnguez?= Date: Tue, 8 Aug 2017 08:21:48 +0200 Subject: [PATCH 2/2] Missing change --- src/win32.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/win32.coffee b/src/win32.coffee index 4e677d4..c53aa52 100644 --- a/src/win32.coffee +++ b/src/win32.coffee @@ -224,7 +224,7 @@ module.exports = @WiFiLog "Success!" @WiFiLog "Removing temporary WiFi config file..." - @execSync "del \".\\#{_ap.ssid}.xml\"" + @execSync "del \".\\" + urlify(_ap.ssid) + ".xml\"" # # In Windows, we are just disconnecting from the current network.