From 1eacd5e346520b54cf849c8ae93d4af5873e9bf6 Mon Sep 17 00:00:00 2001 From: Don Mitchell Date: Fri, 14 Dec 2012 09:45:25 -0500 Subject: [PATCH 1/2] Fix infinite loop in videosourceSample. Had fixed same one in parse_videosource but neglected to fix this one. --- cms/static/js/models/settings/course_details.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cms/static/js/models/settings/course_details.js b/cms/static/js/models/settings/course_details.js index de4831e186..7204e8a525 100644 --- a/cms/static/js/models/settings/course_details.js +++ b/cms/static/js/models/settings/course_details.js @@ -76,8 +76,8 @@ CMS.Models.Settings.CourseDetails = Backbone.Model.extend({ _videoprefix : /\s*]+/g, + _videokeyparse : /([^,\/>]+)/g, + _videonosuffix : /[^"\/>]+/g, _getNextMatch : function (regex, string, cursor) { regex.lastIndex = cursor; var result = regex.exec(string); @@ -113,13 +113,15 @@ CMS.Models.Settings.CourseDetails = Backbone.Model.extend({ cursor = this._videokeyparse.lastIndex + 1; while (cursor < videostring.length && bestspeed != 1.0) { parsedspeed = this._getNextMatch(this._videospeedparse, videostring, cursor); - cursor = this._videospeedparse.lastIndex + 1; + if (parsedspeed) cursor = this._videospeedparse.lastIndex + 1; + else break; if (Math.abs(Number(parsedspeed) - 1.0) < Math.abs(bestspeed - 1.0)) { bestspeed = Number(parsedspeed); bestkey = this._getNextMatch(this._videokeyparse, videostring, cursor); } else this._getNextMatch(this._videokeyparse, videostring, cursor); - cursor = this._videokeyparse.lastIndex + 1; + if (this._videokeyparse.lastIndex > cursor) cursor = this._videokeyparse.lastIndex + 1; + else cursor++; } } else { From b9d9c7b8c062c50687f52dd94fcf01ef335b7ad4 Mon Sep 17 00:00:00 2001 From: Don Mitchell Date: Fri, 14 Dec 2012 09:48:04 -0500 Subject: [PATCH 2/2] Fixed infinite loop in the 2nd video string parser which I'd fixed in the first yesterday. Fixed formatting of compounded video string errors. --- cms/static/js/models/settings/course_details.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cms/static/js/models/settings/course_details.js b/cms/static/js/models/settings/course_details.js index 7204e8a525..446fbd7041 100644 --- a/cms/static/js/models/settings/course_details.js +++ b/cms/static/js/models/settings/course_details.js @@ -61,7 +61,7 @@ CMS.Models.Settings.CourseDetails = Backbone.Model.extend({ // GET "http://gdata.youtube.com/feeds/api/videos/" + videokey } if (!_.isEmpty(vid_errors)) { - errors.intro_video = vid_errors.join('/n'); + errors.intro_video = vid_errors.join(' '); } } if (!_.isEmpty(errors)) return errors;