Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
officejs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
officejs
Commits
a77c6550
Commit
a77c6550
authored
Jul 17, 2014
by
Xiaowu Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add url check
parent
f1cdd9f5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
29 deletions
+48
-29
src/audioplayer_playlist_online/index.html
src/audioplayer_playlist_online/index.html
+1
-1
src/audioplayer_playlist_online/playlist.js
src/audioplayer_playlist_online/playlist.js
+47
-28
No files found.
src/audioplayer_playlist_online/index.html
View file @
a77c6550
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
<script
src=
"./playlist.js"
type=
"text/javascript"
></script>
<script
src=
"./playlist.js"
type=
"text/javascript"
></script>
<body>
<body>
<input
type=
"text"
class=
"inputIp"
placeholder=
"input ip: http://xxx.xxx.xxx.xxx:port/(xxx is between 0 ~ 255)"
/>
<input
type=
"text"
class=
"inputIp"
placeholder=
"input ip: http://xxx.xxx.xxx.xxx:port/(xxx is between 0 ~ 255)
or url
"
/>
<input
type=
"search"
class=
"research"
placeholder=
"research..."
/>
<input
type=
"search"
class=
"research"
placeholder=
"research..."
/>
...
...
src/audioplayer_playlist_online/playlist.js
View file @
a77c6550
/*global window, rJS, RSVP, console, jQuery, $, JSON, Handlebars,
/*global window, rJS, RSVP, console, jQuery, $, JSON, Handlebars,
loopEventListener, RegExp, alert, promiseEventListener */
loopEventListener, RegExp, alert, promiseEventListener */
/*jslint maxlen:180, nomen: true */
/*jslint maxlen:180, nomen: true
, regexp: true
*/
(
function
(
window
,
rJS
,
$
,
Handlebars
,
loopEventListener
)
{
(
function
(
window
,
rJS
,
$
,
Handlebars
,
loopEventListener
)
{
...
@@ -10,13 +10,21 @@
...
@@ -10,13 +10,21 @@
.
getElementById
(
'
network
'
).
innerHTML
,
.
getElementById
(
'
network
'
).
innerHTML
,
network
=
Handlebars
.
compile
(
network_source
);
network
=
Handlebars
.
compile
(
network_source
);
function
endWith
(
str
,
end
)
{
return
(
str
.
indexOf
(
end
,
str
.
length
-
end
.
length
)
!==
-
1
);
}
function
contain
(
str
,
s
)
{
return
(
str
.
indexOf
(
s
)
!==
-
1
);
}
function
checkUrl
(
url
)
{
return
(
contain
(
url
,
"
.com
"
)
||
contain
(
url
,
"
.net
"
)
||
contain
(
url
,
"
.fr
"
));
}
function
checkIp
(
ip
)
{
function
checkIp
(
ip
)
{
var
re
=
/^
(\d{1,2}
|1
\d\d
|2
[
0-4
]\d
|25
[
0-5
])\.(\d{1,2}
|1
\d\d
|2
[
0-4
]\d
|25
[
0-5
])\.(\d{1,2}
|1
\d\d
|2
[
0-4
]\d
|25
[
0-5
])\.(\d{1,2}
|1
\d\d
|2
[
0-4
]\d
|25
[
0-5
])
$/
;
var
re
=
/^
(\d{1,2}
|1
\d\d
|2
[
0-4
]\d
|25
[
0-5
])\.(\d{1,2}
|1
\d\d
|2
[
0-4
]\d
|25
[
0-5
])\.(\d{1,2}
|1
\d\d
|2
[
0-4
]\d
|25
[
0-5
])\.(\d{1,2}
|1
\d\d
|2
[
0-4
]\d
|25
[
0-5
])
$/
;
if
(
!
re
.
test
(
ip
))
{
return
re
.
test
(
ip
);
return
false
;
}
return
true
;
}
}
function
check
(
value
)
{
function
check
(
value
)
{
...
@@ -27,11 +35,17 @@
...
@@ -27,11 +35,17 @@
portEnd
,
portEnd
,
ipValue
=
value
;
ipValue
=
value
;
g
.
__element
.
getElementsByTagName
(
'
ul
'
)[
0
].
innerHTML
=
"
"
;
g
.
__element
.
getElementsByTagName
(
'
ul
'
)[
0
].
innerHTML
=
"
"
;
if
(
ipValue
.
indexOf
(
"
/
"
,
ipValue
.
length
-
1
)
===
-
1
)
{
http
=
ipValue
.
indexOf
(
"
http
"
);
info
.
innerHTML
=
"
not end with /
"
;
if
(
ipValue
.
indexOf
(
"
www.
"
)
!==
-
1
)
{
if
(
http
===
-
1
)
{
info
.
innerHTML
=
"
please start with http:// or https://
"
;
return
;
}
if
(
!
checkUrl
(
ipValue
))
{
info
.
innerHTML
=
"
url invalide
"
;
return
;
return
;
}
}
http
=
ipValue
.
indexOf
(
"
http://
"
);
}
else
{
ipValue
=
ipValue
.
substring
(
ipValue
.
indexOf
(
"
//
"
)
+
2
);
ipValue
=
ipValue
.
substring
(
ipValue
.
indexOf
(
"
//
"
)
+
2
);
port
=
ipValue
.
indexOf
(
"
:
"
);
port
=
ipValue
.
indexOf
(
"
:
"
);
portEnd
=
ipValue
.
indexOf
(
"
:/
"
);
portEnd
=
ipValue
.
indexOf
(
"
:/
"
);
...
@@ -39,18 +53,23 @@
...
@@ -39,18 +53,23 @@
ipValue
=
ipValue
.
substring
(
0
,
port
);
ipValue
=
ipValue
.
substring
(
0
,
port
);
}
}
if
(
http
===
-
1
)
{
if
(
http
===
-
1
)
{
info
.
innerHTML
=
"
please start ip with http://
"
;
info
.
innerHTML
=
"
please start ip with http:// or https://
"
;
return
;
}
if
(
checkIp
(
ipValue
)
===
false
)
{
info
.
innerHTML
=
"
invalide ip: ip should like xxx.xxx.xxx.xxx(xxx is between 0 ~ 255)
"
;
return
;
return
;
}
}
if
(
port
===
-
1
||
portEnd
!==
-
1
)
{
if
(
port
===
-
1
||
portEnd
!==
-
1
)
{
info
.
innerHTML
=
"
input port number
"
;
info
.
innerHTML
=
"
input port number
"
;
return
;
return
;
}
}
if
(
checkIp
(
ipValue
)
===
false
)
{
if
(
!
endWith
(
value
,
"
/
"
))
{
info
.
innerHTML
=
info
.
innerHTML
=
"
not end with /
"
;
"
invalide ip: ip should like xxx.xxx.xxx.xxx(xxx is between 0 ~ 255)
"
;
return
;
return
;
}
}
}
return
new
RSVP
.
Queue
()
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
.
push
(
function
()
{
return
g
.
plSave
({
"
ip
"
:
value
});
return
g
.
plSave
({
"
ip
"
:
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