From 9b9bdb44a3daa72b0ce042f301975b76e9676bdb Mon Sep 17 00:00:00 2001 From: Don Mitchell Date: Thu, 13 Dec 2012 12:58:59 -0500 Subject: [PATCH] Fix video string parse for empty and completely malformed strings --- cms/static/js/models/settings/course_details.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cms/static/js/models/settings/course_details.js b/cms/static/js/models/settings/course_details.js index 222d2fd11e..de4831e186 100644 --- a/cms/static/js/models/settings/course_details.js +++ b/cms/static/js/models/settings/course_details.js @@ -56,6 +56,7 @@ CMS.Models.Settings.CourseDetails = Backbone.Model.extend({ for (var i=0; i]+/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});