Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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
edx
edx-platform
Commits
9b9bdb44
Commit
9b9bdb44
authored
Dec 13, 2012
by
Don Mitchell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix video string parse for empty and completely malformed strings
parent
e75f63e9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
2 deletions
+4
-2
cms/static/js/models/settings/course_details.js
+4
-2
No files found.
cms/static/js/models/settings/course_details.js
View file @
9b9bdb44
...
...
@@ -56,6 +56,7 @@ CMS.Models.Settings.CourseDetails = Backbone.Model.extend({
for
(
var
i
=
0
;
i
<
videos
.
length
;
i
++
)
{
// doesn't call parseFloat or Number b/c they stop on first non parsable and return what they have
if
(
!
isFinite
(
videos
[
i
].
speed
))
vid_errors
.
push
(
videos
[
i
].
speed
+
" is not a valid speed."
);
else
if
(
!
videos
[
i
].
key
)
vid_errors
.
push
(
videos
[
i
].
speed
+
" does not have a video id"
);
// can't use get from client to test if video exists b/c of CORS (crossbrowser get not allowed)
// GET "http://gdata.youtube.com/feeds/api/videos/" + videokey
}
...
...
@@ -76,7 +77,7 @@ CMS.Models.Settings.CourseDetails = Backbone.Model.extend({
// the below is lax to enable validation
_videospeedparse
:
/
[^
:
]
*/g
,
// /\d+\.?\d*(?=:)/g,
_videokeyparse
:
/
([^
,
\/]
+
)
/g
,
_videonosuffix
:
/
[^\"]
+/g
,
_videonosuffix
:
/
[^\"
\/\>
]
+/g
,
_getNextMatch
:
function
(
regex
,
string
,
cursor
)
{
regex
.
lastIndex
=
cursor
;
var
result
=
regex
.
exec
(
string
);
...
...
@@ -141,12 +142,13 @@ CMS.Models.Settings.CourseDetails = Backbone.Model.extend({
cursor
=
0
;
// parsed to "fff:kkk,fff:kkk"
var
result
=
new
Array
();
if
(
!
videostring
||
videostring
.
length
==
0
)
return
result
;
while
(
cursor
<
videostring
.
length
)
{
var
speed
=
this
.
_getNextMatch
(
this
.
_videospeedparse
,
videostring
,
cursor
);
if
(
speed
)
cursor
=
this
.
_videospeedparse
.
lastIndex
+
1
;
else
return
result
;
var
key
=
this
.
_getNextMatch
(
this
.
_videokeyparse
,
videostring
,
cursor
);
cursor
=
this
.
_videokeyparse
.
lastIndex
+
1
;
if
(
key
)
cursor
=
this
.
_videokeyparse
.
lastIndex
+
1
;
// See the WTF above
if
(
_
.
isArray
(
key
))
key
=
key
[
0
];
result
.
push
({
speed
:
speed
,
key
:
key
});
...
...
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