Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Eben Blaisdell
blockcode
Commits
41037d7b
Commit
41037d7b
authored
Feb 08, 2017
by
Eben Blaisdell
Browse files
safe strats
parent
4999c863
Changes
1
Hide whitespace changes
Inline
Side-by-side
index.js
View file @
41037d7b
...
...
@@ -24,7 +24,7 @@ app.use('/', express.static(path.join(__dirname, 'public')));
app
.
post
(
'
/signup
'
,
function
(
req
,
res
)
{
username
=
req
.
body
.
username
;
if
(
username
==
""
||
username
.
indexOf
(
"
..
"
)
!=
-
1
){
if
(
checkFileSafe
(
username
)
){
res
.
send
(
"
Username of Invalid Form Taken.
"
);
return
;
}
...
...
@@ -76,6 +76,10 @@ app.post('/signup', function (req, res) {
});
app
.
post
(
'
/push
'
,
function
(
req
,
res
)
{
if
(
!
checkFileSafe
(
req
.
body
.
strat
)){
res
.
send
(
"
Invalid Strat.
"
);
return
;
}
username
=
req
.
body
.
username
;
password
=
req
.
body
.
password
;
login
(
username
,
password
,
res
,
function
(
userinfo
){
...
...
@@ -91,6 +95,10 @@ app.post('/push', function (req, res) {
});
app
.
post
(
'
/pull
'
,
function
(
req
,
res
)
{
if
(
!
checkFileSafe
(
req
.
body
.
strat
)){
res
.
send
(
"
Invalid Strat.
"
);
return
;
}
username
=
req
.
body
.
username
;
password
=
req
.
body
.
password
;
login
(
username
,
password
,
res
,
function
(
userinfo
){
...
...
@@ -281,6 +289,10 @@ function ipAddresses(){
return
addresses
;
}
function
checkFileSafe
(
filename
){
filename
==
""
||
filename
.
indexOf
(
"
..
"
)
!=
-
1
||
filename
.
indexOf
(
"
~
"
)
!=
-
1
||
filename
.
indexOf
(
"
/
"
)
!=
-
1
;
}
function
findWithAttr
(
array
,
attr
,
value
)
{
for
(
var
i
=
0
;
i
<
array
.
length
;
i
+=
1
)
{
if
(
array
[
i
][
attr
]
===
value
)
{
...
...
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