Skip to content

Commit

Permalink
#18 Xiaomi QR format update
Browse files Browse the repository at this point in the history
  • Loading branch information
kokoye2007 committed May 21, 2023
1 parent cc1643b commit a7be40c
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 5 deletions.
7 changes: 6 additions & 1 deletion debian/changelog
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
wifi-qr (0.2-3+18) unstable; urgency=medium

* #18 Xiaomi QR code is parsed incorrectly.

-- kokoye2007 <[email protected]> Mon, 22 May 2023 04:32:35 +1000

wifi-qr (0.2-3) unstable; urgency=medium

* #12 Password with special characters needs to be unquoted.
* #17 QR issue when the name and SSID differ.
* #16 QR issue when the password has special characters.
* #15 QR issue when the SSID has special characters.
Expand Down
41 changes: 41 additions & 0 deletions debian/patches/0.2-3+18
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
Description: Xiaomi QR code is parsed incorrectly.
Xiaomi use own template.
.
wifi-qr (0.2-3) unstable; urgency=medium
.
* #18 Xiaomi QR code is parsed incorrectly.
* #17 QR issue when the name and SSID differ.
* #16 QR issue when the password has special characters.
* #15 QR issue when the SSID has special characters.
* #12 Password with special characters needs to be unquoted.
Author: kokoye2007 <[email protected]>

---
Origin: upstream, https://github.com/kokoye2007/wifi-qr
Forwarded: not-needed
Reviewed-By: kokoye2007 <[email protected]>
Last-Update: 2023-05-21

--- wifi-qr-0.2.orig/wifi-qr
+++ wifi-qr-0.2/wifi-qr
@@ -258,16 +258,16 @@ call_wifi_scan() {
WIFIQRDATA="${wifiqrdata}"

# Extract the SSID
- QSSID=$(echo "$WIFIQRDATA" | sed -n 's/.*S:\(.*\);T.*/\1/p' | sed 's/\\\([\\;,:"\]\)/\1/g' )
+ QSSID=$(echo "$WIFIQRDATA" | sed -n 's/.*S:\([^;]*\)\(;[PHT]\).*$/\1/p' | sed 's/\\\([\\;,:"\]\)/\1/g' )

# Extract the security type
- QTYPE=$(echo "$WIFIQRDATA" | sed -n 's/.*T:\(.*\);P.*/\1/p')
+ QTYPE=$(echo "$WIFIQRDATA" | sed -n 's/.*T:\([^;]*\)\(;[PHS]\).*$/\1/p' | sed 's/\\\([\\;,:"\]\)/\1/g' )

# Extract the password
if [[ $WIFIQRDATA == *';H:'* ]]; then
- QKEES=$(echo "$WIFIQRDATA" | sed -n 's/.*;P:\(.*\);H:.*/\1/p' | sed 's/\\:/:/g' | sed 's/\\\([\\;,:"\]\)/\1/g' )
+ QKEES=$(echo "$WIFIQRDATA" | sed -n 's/.*P:\([^;]*\)\(;[TSH]\).*$/\1/p' | sed 's/\\\([\\;,:"\]\)/\1/g' )
else
- QKEES=$(echo "$WIFIQRDATA" | sed -n 's/.*;P:\(.*\);;.*/\1/p' | sed 's/\\:/:/g' | sed 's/\\\([\\;,:"\]\)/\1/g' )
+ QKEES=$(echo "$WIFIQRDATA" | sed -n 's/.*P:\([^;]*\)\(;[TS]\).*$/\1/p' | sed 's/\\\([\\;,:"\]\)/\1/g' )
fi

# Check if the Wi-Fi network is hidden
1 change: 1 addition & 0 deletions debian/patches/series
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
01-QR-Code-Scan-From-File
0.2-3_update
0.2-3+18
8 changes: 4 additions & 4 deletions wifi-qr
Original file line number Diff line number Diff line change
Expand Up @@ -258,16 +258,16 @@ call_wifi_scan() {
WIFIQRDATA="${wifiqrdata}"

# Extract the SSID
QSSID=$(echo "$WIFIQRDATA" | sed -n 's/.*S:\(.*\);T.*/\1/p' | sed 's/\\\([\\;,:"\]\)/\1/g' )
QSSID=$(echo "$WIFIQRDATA" | sed -n 's/.*S:\([^;]*\)\(;[PHT]\).*$/\1/p' | sed 's/\\\([\\;,:"\]\)/\1/g' )

# Extract the security type
QTYPE=$(echo "$WIFIQRDATA" | sed -n 's/.*T:\(.*\);P.*/\1/p')
QTYPE=$(echo "$WIFIQRDATA" | sed -n 's/.*T:\([^;]*\)\(;[PHS]\).*$/\1/p' | sed 's/\\\([\\;,:"\]\)/\1/g' )

# Extract the password
if [[ $WIFIQRDATA == *';H:'* ]]; then
QKEES=$(echo "$WIFIQRDATA" | sed -n 's/.*;P:\(.*\);H:.*/\1/p' | sed 's/\\:/:/g' | sed 's/\\\([\\;,:"\]\)/\1/g' )
QKEES=$(echo "$WIFIQRDATA" | sed -n 's/.*P:\([^;]*\)\(;[TSH]\).*$/\1/p' | sed 's/\\\([\\;,:"\]\)/\1/g' )
else
QKEES=$(echo "$WIFIQRDATA" | sed -n 's/.*;P:\(.*\);;.*/\1/p' | sed 's/\\:/:/g' | sed 's/\\\([\\;,:"\]\)/\1/g' )
QKEES=$(echo "$WIFIQRDATA" | sed -n 's/.*P:\([^;]*\)\(;[TS]\).*$/\1/p' | sed 's/\\\([\\;,:"\]\)/\1/g' )
fi

# Check if the Wi-Fi network is hidden
Expand Down

0 comments on commit a7be40c

Please sign in to comment.