Skip to content

Commit d43f358

Browse files
committed
webui: improve field validation on the OpenVPN client page
1 parent 30b0653 commit d43f358

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

release/src/router/www/Advanced_OpenVPNClient_Content.asp

+28
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,32 @@ function cal_panel_block(){
519519
}
520520
521521
522+
function validForm(){
523+
var addrobj = document.form.vpn_client_addr;
524+
var alert_str = validator.domainName(addrobj);
525+
if ((addrobj.value != "") && (alert_str != "") && (!validator.ipv4_addr(addrobj.value))) {
526+
alert("Invalid remote server address!");
527+
addrobj.focus();
528+
return false;
529+
}
530+
531+
if (!validator.safeName(document.form.vpn_client_desc) ||
532+
!validator.numberRange(document.form.vpn_client_verb, 0, 6) ||
533+
!validator.numberRange(document.form.vpn_client_poll, 0, 60) ||
534+
!validator.numberRange(document.form.vpn_client_reneg, -1, 2147483647) ||
535+
!validator.numberRange(document.form.vpn_client_retry, -1, 32767) ||
536+
!validator.numberRange(document.form.vpn_client_port, 1, 65535))
537+
return false;
538+
539+
return true;
540+
}
541+
542+
522543
function applyRule(manual_switch){
544+
if (!validForm()){
545+
return false;
546+
}
547+
523548
if (manual_switch == 0) {
524549
showLoading();
525550
if (client_state != 0) {
@@ -702,6 +727,9 @@ function addRow_Group(upper){
702727
return false;
703728
}
704729
730+
if (!validator.safeName(document.form.clientlist_deviceName))
731+
return false;
732+
705733
if(document.form.clientlist_ipAddr.value=="")
706734
document.form.clientlist_ipAddr.value="0.0.0.0";
707735

0 commit comments

Comments
 (0)