mirror of https://github.com/huashengdun/webssh
Use read_file_as_text to valiate the private key
parent
6cfcaddadf
commit
ee7fd101c6
|
@ -78,7 +78,7 @@ jQuery(function($){
|
||||||
try {
|
try {
|
||||||
text = decoder.decode(reader.result);
|
text = decoder.decode(reader.result);
|
||||||
} catch (TypeError) {
|
} catch (TypeError) {
|
||||||
console.error('Decoding error happened.');
|
console.log('Decoding error happened.');
|
||||||
} finally {
|
} finally {
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback(text);
|
callback(text);
|
||||||
|
@ -288,27 +288,7 @@ jQuery(function($){
|
||||||
port = data.get('port'),
|
port = data.get('port'),
|
||||||
username = data.get('username');
|
username = data.get('username');
|
||||||
|
|
||||||
if (!hostname || !port || !username) {
|
function ajax_post() {
|
||||||
status.text('Fields hostname, port and username are all required.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!hostname_tester.test(hostname)) {
|
|
||||||
status.text('Invalid hostname: ' + hostname);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (port <= 0 || port > 63335) {
|
|
||||||
status.text('Invalid port: ' + port);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var pk = data.get('privatekey');
|
|
||||||
if (pk && pk.size > key_max_size) {
|
|
||||||
status.text('Invalid private key: ' + pk.name);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
store_items(names, data);
|
store_items(names, data);
|
||||||
|
|
||||||
status.text('');
|
status.text('');
|
||||||
|
@ -325,6 +305,39 @@ jQuery(function($){
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!hostname || !port || !username) {
|
||||||
|
status.text('Fields hostname, port and username are all required.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hostname_tester.test(hostname)) {
|
||||||
|
status.text('Invalid hostname: ' + hostname);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (port <= 0 || port > 63335) {
|
||||||
|
status.text('Invalid port: ' + port);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var pk = data.get('privatekey');
|
||||||
|
if (pk) {
|
||||||
|
if (pk.size > key_max_size) {
|
||||||
|
status.text('Invalid private key: ' + pk.name);
|
||||||
|
} else {
|
||||||
|
read_file_as_text(pk, function(text) {
|
||||||
|
if (text === undefined) {
|
||||||
|
status.text('Invalid private key: ' + pk.name);
|
||||||
|
} else {
|
||||||
|
ajax_post();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ajax_post();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
wssh.connect = connect;
|
wssh.connect = connect;
|
||||||
|
|
||||||
$(form_id).submit(function(event){
|
$(form_id).submit(function(event){
|
||||||
|
|
Loading…
Reference in New Issue