Fix WiFi PSK special character escaping in wpa_supplicant.conf - #38
Draft
glynhudson with Copilot wants to merge 3 commits into
Draft
glynhudson with Copilot wants to merge 3 commits into
glynhudson with Copilot wants to merge 3 commits into
Conversation
Contributor
Author
|
@glynhudson 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs. I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review. |
Co-authored-by: glynhudson <758844+glynhudson@users.noreply.github.com>
Co-authored-by: glynhudson <758844+glynhudson@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Special characters in WiFi PSK not being properly escaped
Fix WiFi PSK special character escaping in wpa_supplicant.conf
Sep 15, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WiFi PSKs (passwords) containing special characters were not being properly escaped when written to the wpa_supplicant configuration file, potentially causing configuration corruption and connection failures.
Problem
The
setconfig()method in theWificlass was directly inserting PSK values into the wpa_supplicant.conf file without proper escaping. This could break the configuration file format when passwords contained characters like double quotes, backslashes, or control characters.For example, a password like
my"passwordwould generate:This malformed configuration could prevent WiFi connections from working.
Solution
escapeWpaSupplicantString()that properly escapes special characters for wpa_supplicant.conf formatsetconfig()method to escape both SSID and PSK values before writing them to the configuration file"), backslashes (\), newlines (\n), tabs (\t), and carriage returns (\r)Characters Handled
The fix properly handles all the characters mentioned in the issue (
&,',(,),@,^,_,|) as well as other potentially problematic characters. Most of these characters don't require escaping when inside quoted strings, but the implementation ensures robust handling of edge cases.Testing
Comprehensive testing was performed with various password combinations including:
The fix is minimal and backward-compatible, ensuring existing configurations continue to work while properly handling special characters going forward.
Fixes #37.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
https://api.github.com/repos/php-parallel-lint/PHP-Parallel-Lint/zipball/6db563514f27e19595a19f45a4bf757b6401194e/usr/bin/php8.3 -n -c /tmp/6RC9xL /usr/bin/composer install(http block)If you need me to access, download, or install something from one of these locations, you can either:
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.