Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
webssh
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
郑天保
webssh
Commits
f09ba9ec
Commit
f09ba9ec
authored
Aug 21, 2018
by
Sheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added js code for validating hostname and port
parent
38cb22ac
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
8 deletions
+21
-8
main.js
webssh/static/js/main.js
+21
-8
No files found.
webssh/static/js/main.js
View file @
f09ba9ec
...
...
@@ -118,16 +118,14 @@ jQuery(function($){
console
.
log
(
'Reset encoding to '
+
msg
.
encoding
);
};
wssh
.
resize_terminal
=
function
(
raw_cols
,
raw_
rows
)
{
wssh
.
resize_terminal
=
function
(
cols
,
rows
)
{
// for console use
if
(
term
===
undefined
)
{
console
.
log
(
'Terminal was already destroryed'
);
return
;
}
var
cols
=
parseInt
(
raw_cols
,
10
),
rows
=
parseInt
(
raw_rows
,
10
),
valid_args
=
false
;
var
valid_args
=
false
;
if
(
cols
>
0
&&
rows
>
0
)
{
var
geometry
=
current_geometry
();
...
...
@@ -210,15 +208,30 @@ jQuery(function($){
var
form
=
$
(
this
),
url
=
form
.
attr
(
'action'
),
type
=
form
.
attr
(
'method'
),
data
=
new
FormData
(
this
);
data
=
new
FormData
(
this
),
hostname
=
data
.
get
(
'hostname'
),
port
=
data
.
get
(
'port'
),
username
=
data
.
get
(
'username'
),
key_max_size
=
16384
,
hostname_tester
=
/
((
^
\s
*
((([
0-9
]
|
[
1-9
][
0-9
]
|1
[
0-9
]{2}
|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0-5
]
|2
[
0-4
]\d
|1
\d\d
|
[
1-9
]?\d)){3}))
|:
))
|
(([
0-9A-Fa-f
]{1,4}
:
){1}(((
:
[
0-9A-Fa-f
]{1,4}){1,6})
|
((
:
[
0-9A-Fa-f
]{1,4}){0,4}
:
((
25
[
0-5
]
|2
[
0-4
]\d
|1
\d\d
|
[
1-9
]?\d)(\.(
25
[
0-5
]
|2
[
0-4
]\d
|1
\d\d
|
[
1-9
]?\d)){3}))
|:
))
|
(
:
(((
:
[
0-9A-Fa-f
]{1,4}){1,7})
|
((
:
[
0-9A-Fa-f
]{1,4}){0,5}
:
((
25
[
0-5
]
|2
[
0-4
]\d
|1
\d\d
|
[
1-9
]?\d)(\.(
25
[
0-5
]
|2
[
0-4
]\d
|1
\d\d
|
[
1-9
]?\d)){3}))
|:
)))(
%.+
)?\s
*$
))
|
(
^
\s
*
((?=
.
{1,255}
$
)(?=
.*
[
A-Za-z
]
.*
)[
0-9A-Za-z
](?:(?:[
0-9A-Za-z
]
|
\b
-
){0,61}[
0-9A-Za-z
])?(?:\.[
0-9A-Za-z
](?:(?:[
0-9A-Za-z
]
|
\b
-
){0,61}[
0-9A-Za-z
])?)
*
)\s
*$
)
/
;
if
(
!
hostname
||
!
port
||
!
username
)
{
status
.
text
(
'Fields hostname, port and username are all required.'
);
return
;
}
if
(
!
hostname_tester
.
test
(
hostname
))
{
status
.
text
(
'Not a valid hostname '
+
hostname
);
return
;
}
if
(
!
data
.
get
(
'hostname'
)
||
!
data
.
get
(
'port'
)
||
!
data
.
get
(
'username'
)
)
{
status
.
text
(
'
Hostname, port and username are required.'
);
if
(
port
<=
0
||
port
>
63335
)
{
status
.
text
(
'
Not a valid port '
+
port
);
return
;
}
var
pk
=
data
.
get
(
'privatekey'
);
if
(
pk
&&
pk
.
size
>
16384
)
{
if
(
pk
&&
pk
.
size
>
key_max_size
)
{
status
.
text
(
'Key size exceeds the maximum value.'
);
return
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment