Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Password contains double quotation marks in helper.make_wifi_data result #95

Closed
dolphinwow opened this issue Feb 10, 2021 · 4 comments
Closed
Assignees
Labels

Comments

@dolphinwow
Copy link

Try to get the qrcode value by using helper.make_wifi_data.
However, among the generated qrcode result values, double quotation marks are included in the password.
Because of this, a password error occurs when scanning with a qrcode scanner.

I hope to check if there is a problem with my code.

My Code ====
qrVal = helpers.make_wifi_data(
ssid=contentJson.get('ssid'),
password=contentJson.get('password'),
security=contentJson.get('security'),
hidden=contentJson.get('hidden') == True)

Result ====
WIFI:T:WPA;S:"MySSID";P:"MyPassword";;

@heuer
Copy link
Owner

heuer commented Feb 10, 2021

Thanks for your report. I cannot reproduce this, maybe the JSON data already contain quotation marks?

>>> import segno.helpers
>>> segno.helpers.make_wifi_data(ssid='MySSID', password='MyPassword', security='wpa')
'WIFI:T:WPA;S:MySSID;P:MyPassword;;'
>>> segno.helpers.make_wifi_data(ssid='MySSID', password='MyPassword', security='wpa', hidden=True)
'WIFI:T:WPA;S:MySSID;P:MyPassword;H:true;'

@dolphinwow
Copy link
Author

dolphinwow commented Feb 12, 2021

Hi, @heuer
thank you for your reply.

In my case, I got different results as below.

------- my source code ------

if request.method == 'POST':
    content = request.data.get('content')

	contentJson = json.loads(content)
	qrVal = helpers.make_wifi_data(
	    ssid=contentJson.get('ssid'),
	    password=contentJson.get('password'),
	    security=contentJson.get('security'),
	    hidden=contentJson.get('hidden') == True)

------- success case -------
['content' value]
{"qrtype":"wifi","ssid":"myssid","password":"mypassward","security":"WPA","hidden":true}

['helpers.make_wifi_data' result]
WIFI:T:WPA;S:myssid;P:mypassward;H:true;

------- failed case -------
['content' value]
{"qrtype":"wifi","ssid":"myssid","password":"12341234","security":"WPA","hidden":true}

['helpers.make_wifi_data' result]
WIFI:T:WPA;S:myssid;P:"12341234";H:true;

@heuer
Copy link
Owner

heuer commented Feb 12, 2021

Thanks for providing more insight into your code. Now I understand why the password is quoted. It should only happen if the password / SSID can be interpreted as an integer.
I'll fix it asap.

@heuer heuer self-assigned this Feb 12, 2021
@heuer heuer added the bug label Feb 12, 2021
@dolphinwow
Copy link
Author

@heuer Thank you for the quick answer. ^^

@heuer heuer closed this as completed in c1dbbea Mar 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants