From 4168a061355741d15837677bf96db3c1f930aaf2 Mon Sep 17 00:00:00 2001 From: TheObliterator Date: Fri, 31 Jul 2020 00:44:55 +0100 Subject: [PATCH] Fix connection to access points containing Latin diacritic characters in their SSID name SSIDs names now processed as UTF8 to preserve accented/diacritic/unicode characters. The name is also now escaped before output to the XML profile. The WLAN profile XML templates have been updated to UFT8 format and to include the hex ssid. This was required for the connection to work with accented/diacritic/unicode characters. # Conflicts: # SimpleWifi/ProfileFactory.cs --- SimpleWifi/ProfileFactory.cs | 15 +++++++++------ SimpleWifi/ProfileXML/OPEN.xml | 2 +- SimpleWifi/ProfileXML/WEP.xml | 2 +- .../ProfileXML/WPA-Enterprise-PEAP-MSCHAPv2.xml | 3 ++- SimpleWifi/ProfileXML/WPA-Enterprise-TLS.xml | 3 ++- SimpleWifi/ProfileXML/WPA-PSK.xml | 7 ++++--- .../ProfileXML/WPA2-Enterprise-PEAP-MSCHAPv2.xml | 3 ++- SimpleWifi/ProfileXML/WPA2-Enterprise-TLS.xml | 3 ++- SimpleWifi/ProfileXML/WPA2-PSK.xml | 5 +++-- 9 files changed, 26 insertions(+), 17 deletions(-) diff --git a/SimpleWifi/ProfileFactory.cs b/SimpleWifi/ProfileFactory.cs index 8b78821..41fbe6b 100644 --- a/SimpleWifi/ProfileFactory.cs +++ b/SimpleWifi/ProfileFactory.cs @@ -18,8 +18,11 @@ internal static string Generate(WlanAvailableNetwork network, string password) { string profile = string.Empty; string template = string.Empty; - string name = Encoding.ASCII.GetString(network.dot11Ssid.SSID, 0, (int)network.dot11Ssid.SSIDLength); - string hex = GetHexString(network.dot11Ssid.SSID); + string name = Encoding.UTF8.GetString(network.dot11Ssid.SSID, 0, (int)network.dot11Ssid.SSIDLength); + string hex = GetHexString(network.dot11Ssid.SSID); + + name = System.Security.SecurityElement.Escape(name); + password = System.Security.SecurityElement.Escape(password); var authAlgo = network.dot11DefaultAuthAlgorithm; @@ -37,12 +40,12 @@ internal static string Generate(WlanAvailableNetwork network, string password) if (authAlgo == Dot11AuthAlgorithm.RSNA) { template = GetTemplate("WPA2-Enterprise-PEAP-MSCHAPv2"); - profile = string.Format(template, name); + profile = string.Format(template, name, hex); } else // PSK { template = GetTemplate("WPA2-PSK"); - profile = string.Format(template, name, password); + profile = string.Format(template, name, hex, password); } break; case Dot11CipherAlgorithm.TKIP: @@ -50,12 +53,12 @@ internal static string Generate(WlanAvailableNetwork network, string password) if (authAlgo == Dot11AuthAlgorithm.RSNA) { template = GetTemplate("WPA-Enterprise-PEAP-MSCHAPv2"); - profile = string.Format(template, name); + profile = string.Format(template, name, hex); } else // PSK { template = GetTemplate("WPA-PSK"); - profile = string.Format(template, name, password); + profile = string.Format(template, name, hex, password); } break; diff --git a/SimpleWifi/ProfileXML/OPEN.xml b/SimpleWifi/ProfileXML/OPEN.xml index aeba700..5256fe8 100644 --- a/SimpleWifi/ProfileXML/OPEN.xml +++ b/SimpleWifi/ProfileXML/OPEN.xml @@ -1,4 +1,4 @@ - + {0} diff --git a/SimpleWifi/ProfileXML/WEP.xml b/SimpleWifi/ProfileXML/WEP.xml index 9cbb5a4..d9597ab 100644 --- a/SimpleWifi/ProfileXML/WEP.xml +++ b/SimpleWifi/ProfileXML/WEP.xml @@ -1,4 +1,4 @@ - + {0} diff --git a/SimpleWifi/ProfileXML/WPA-Enterprise-PEAP-MSCHAPv2.xml b/SimpleWifi/ProfileXML/WPA-Enterprise-PEAP-MSCHAPv2.xml index 95295bd..a9c32e2 100644 --- a/SimpleWifi/ProfileXML/WPA-Enterprise-PEAP-MSCHAPv2.xml +++ b/SimpleWifi/ProfileXML/WPA-Enterprise-PEAP-MSCHAPv2.xml @@ -1,8 +1,9 @@ - + {0} + {1} {0} diff --git a/SimpleWifi/ProfileXML/WPA-Enterprise-TLS.xml b/SimpleWifi/ProfileXML/WPA-Enterprise-TLS.xml index 071320a..65e1fb1 100644 --- a/SimpleWifi/ProfileXML/WPA-Enterprise-TLS.xml +++ b/SimpleWifi/ProfileXML/WPA-Enterprise-TLS.xml @@ -1,8 +1,9 @@ - + {0} + {1} {0} false diff --git a/SimpleWifi/ProfileXML/WPA-PSK.xml b/SimpleWifi/ProfileXML/WPA-PSK.xml index 7123a5c..28794d8 100644 --- a/SimpleWifi/ProfileXML/WPA-PSK.xml +++ b/SimpleWifi/ProfileXML/WPA-PSK.xml @@ -1,9 +1,10 @@ - + {0} - {0} + {1} + {0} ESS @@ -19,7 +20,7 @@ passPhrase false - {1} + {2} diff --git a/SimpleWifi/ProfileXML/WPA2-Enterprise-PEAP-MSCHAPv2.xml b/SimpleWifi/ProfileXML/WPA2-Enterprise-PEAP-MSCHAPv2.xml index 6ae2b7a..8cc9ebc 100644 --- a/SimpleWifi/ProfileXML/WPA2-Enterprise-PEAP-MSCHAPv2.xml +++ b/SimpleWifi/ProfileXML/WPA2-Enterprise-PEAP-MSCHAPv2.xml @@ -1,8 +1,9 @@ - + {0} + {1} {0} diff --git a/SimpleWifi/ProfileXML/WPA2-Enterprise-TLS.xml b/SimpleWifi/ProfileXML/WPA2-Enterprise-TLS.xml index 61dee8c..b408c20 100644 --- a/SimpleWifi/ProfileXML/WPA2-Enterprise-TLS.xml +++ b/SimpleWifi/ProfileXML/WPA2-Enterprise-TLS.xml @@ -1,8 +1,9 @@ - + {0} + {1} {0} diff --git a/SimpleWifi/ProfileXML/WPA2-PSK.xml b/SimpleWifi/ProfileXML/WPA2-PSK.xml index d6cd1d3..ad88713 100644 --- a/SimpleWifi/ProfileXML/WPA2-PSK.xml +++ b/SimpleWifi/ProfileXML/WPA2-PSK.xml @@ -1,8 +1,9 @@ - + {0} + {1} {0} @@ -19,7 +20,7 @@ passPhrase false - {1} + {2}