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
Hide 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 @@
<script
src=
"./playlist.js"
type=
"text/javascript"
></script>
<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..."
/>
...
...
src/audioplayer_playlist_online/playlist.js
View file @
a77c6550
/*global window, rJS, RSVP, console, jQuery, $, JSON, Handlebars,
loopEventListener, RegExp, alert, promiseEventListener */
/*jslint maxlen:180, nomen: true */
/*jslint maxlen:180, nomen: true
, regexp: true
*/
(
function
(
window
,
rJS
,
$
,
Handlebars
,
loopEventListener
)
{
...
...
@@ -10,13 +10,21 @@
.
getElementById
(
'
network
'
).
innerHTML
,
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
)
{
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
false
;
}
return
true
;
return
re
.
test
(
ip
);
}
function
check
(
value
)
{
...
...
@@ -27,29 +35,40 @@
portEnd
,
ipValue
=
value
;
g
.
__element
.
getElementsByTagName
(
'
ul
'
)[
0
].
innerHTML
=
"
"
;
if
(
ipValue
.
indexOf
(
"
/
"
,
ipValue
.
length
-
1
)
===
-
1
)
{
info
.
innerHTML
=
"
not end with /
"
;
return
;
}
http
=
ipValue
.
indexOf
(
"
http://
"
);
ipValue
=
ipValue
.
substring
(
ipValue
.
indexOf
(
"
//
"
)
+
2
);
port
=
ipValue
.
indexOf
(
"
:
"
);
portEnd
=
ipValue
.
indexOf
(
"
:/
"
);
if
(
port
!==
-
1
)
{
ipValue
=
ipValue
.
substring
(
0
,
port
);
}
if
(
http
===
-
1
)
{
info
.
innerHTML
=
"
please start ip with http://
"
;
return
;
}
if
(
port
===
-
1
||
portEnd
!==
-
1
)
{
info
.
innerHTML
=
"
input port number
"
;
return
;
}
if
(
checkIp
(
ipValue
)
===
false
)
{
info
.
innerHTML
=
"
invalide ip: ip should like xxx.xxx.xxx.xxx(xxx is between 0 ~ 255)
"
;
return
;
http
=
ipValue
.
indexOf
(
"
http
"
);
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
;
}
}
else
{
ipValue
=
ipValue
.
substring
(
ipValue
.
indexOf
(
"
//
"
)
+
2
);
port
=
ipValue
.
indexOf
(
"
:
"
);
portEnd
=
ipValue
.
indexOf
(
"
:/
"
);
if
(
port
!==
-
1
)
{
ipValue
=
ipValue
.
substring
(
0
,
port
);
}
if
(
http
===
-
1
)
{
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
;
}
if
(
port
===
-
1
||
portEnd
!==
-
1
)
{
info
.
innerHTML
=
"
input port number
"
;
return
;
}
if
(
!
endWith
(
value
,
"
/
"
))
{
info
.
innerHTML
=
"
not end with /
"
;
return
;
}
}
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
...
...
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