mirror of
https://github.com/oopuuu/zTC1.git
synced 2025-12-12 13:08:13 +08:00
Sorry, can't use ' or " or space.
This commit is contained in:
@@ -119,21 +119,15 @@ static int http_set_wifi_config(httpd_request_t *req)
|
||||
{
|
||||
OSStatus err = kNoErr;
|
||||
|
||||
int buf_size = 512;
|
||||
int ssid_size = 32;
|
||||
int key_size = 64;
|
||||
int buf_size = 97;
|
||||
char *buf = malloc(buf_size);
|
||||
char *wifi_ssid = malloc(ssid_size);
|
||||
char *wifi_key = malloc(key_size);
|
||||
char *wifi_ssid = malloc(32);
|
||||
char *wifi_key = malloc(64);
|
||||
|
||||
err = httpd_get_data(req, buf, buf_size);
|
||||
require_noerr(err, exit);
|
||||
|
||||
err = httpd_get_tag_from_post_data(buf, "ssid", wifi_ssid, ssid_size);
|
||||
require_noerr(err, exit);
|
||||
|
||||
err = httpd_get_tag_from_post_data(buf, "key", wifi_key, key_size);
|
||||
require_noerr(err, exit);
|
||||
sscanf(buf, "%s %s", wifi_ssid, wifi_key);
|
||||
|
||||
wifi_connect(wifi_ssid, wifi_key);
|
||||
|
||||
|
||||
@@ -310,11 +310,30 @@ function ChangeInput(type) {
|
||||
}
|
||||
}
|
||||
|
||||
function SubmitNetwork() {
|
||||
if(mode == 1) {
|
||||
//Quotation Marks
|
||||
function ContainQM(str) {
|
||||
if (str.indexOf("'") >= 0
|
||||
|| str.indexOf('"') >= 0
|
||||
|| str.indexOf(' ') >= 0
|
||||
|| str.length > 32) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
var qm_mess = "Sorry, can't use ' or \" or space.\n\nAlso, length <= 32."
|
||||
|
||||
function SubmitNetwork() {
|
||||
if(mode != 1) {
|
||||
if (ContainQM(ap_name) || ContainQM(ap_pswd)) {
|
||||
alert(qm_mess);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
var params = "ssid="+station_name+"&key="+station_pswd;
|
||||
if (ContainQM(station_name) || ContainQM(station_pswd)) {
|
||||
alert(qm_mess);
|
||||
return;
|
||||
}
|
||||
var params = station_name+" "+station_pswd;
|
||||
HttpPost("/wifi/config", function (re) {
|
||||
alert(re);
|
||||
}, params);
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -89,9 +89,10 @@ void wifi_scan_callback(ScanResult_adv* scan_ret, void* arg)
|
||||
char* tmp2 = secs;
|
||||
for (; i < count; i++)
|
||||
{
|
||||
sprintf(tmp1, "'%s',", scan_ret->ApList[i].ssid);
|
||||
tmp1 += (strlen(scan_ret->ApList[i].ssid) + 3);
|
||||
|
||||
char* ssid = scan_ret->ApList[i].ssid;
|
||||
if (strstr(ssid, "'") || strstr(ssid, "\"")) continue;
|
||||
sprintf(tmp1, "'%s',", ssid);
|
||||
tmp1 += (strlen(ssid) + 3);
|
||||
sprintf(tmp2, "%d,", scan_ret->ApList[i].security);
|
||||
tmp2 += 2;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user