DigiExam / simplewifi

.NET 4.5 library to manage wifi connections in Windows - written in C#
GNU Lesser General Public License v3.0
131 stars 82 forks source link

Not able to connect to a WLAN in case the SSID contains a '&' in its name #22

Open jomanu85 opened 8 years ago

jomanu85 commented 8 years ago

I was trying to connect to my WLAN, which got an '&' in its name.... But it simply never worked... After a while (was already getting my head around the Managed Wifi API) I got the Idea to try it with a SSID Name not containing any special characters... et voila, this worked.

So in order to get the Simple Wifi API to work also with more exotic SSIDs simply add a HttpUtility.HtmlEncode() around the name in ProfileFactory.cs.

string name = HttpUtility.HtmlEncode(Encoding.ASCII.GetString(network.dot11Ssid.SSID, 0, (int)network.dot11Ssid.SSIDLength));

Hope this is usefull to anybody :)

k00ala commented 8 years ago

THX, i had to include the namespace: using System.Net;

And i used the class WebUtility because my application is no webapplication ;) string name = WebUtility.HtmlEncode(Encoding.ASCII.GetString(network.dot11Ssid.SSID, 0, (int)network.dot11Ssid.SSIDLength));

TheObliterator commented 4 years ago

See #45. I opted to use SecurityElement.Escape as this only escapes XML affected characters.

However, I found escaping the ssid name on its own wasn't sufficient for more exotic SSIDs (even using full html entity encoding). To fix connection for those, I had to also include the hex key in the profile to connect to those.