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
6cb5c390
Commit
6cb5c390
authored
Oct 25, 2013
by
polesye
Committed by
Valera Rozuvan
Oct 30, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BLD-408: Don't allow users to enter video url's in http.
parent
80c83f0b
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
63 additions
and
46 deletions
+63
-46
CHANGELOG.rst
+2
-0
cms/djangoapps/contentstore/features/transcripts.feature
+0
-0
cms/djangoapps/contentstore/views/item.py
+13
-1
cms/static/js/views/transcripts/utils.js
+4
-2
cms/static/js_spec/transcripts/editor_spec.js
+28
-28
cms/static/js_spec/transcripts/utils_spec.js
+11
-10
cms/static/js_spec/transcripts/videolist_spec.js
+5
-5
No files found.
CHANGELOG.rst
View file @
6cb5c390
...
@@ -5,6 +5,8 @@ These are notable changes in edx-platform. This is a rolling list of changes,
...
@@ -5,6 +5,8 @@ These are notable changes in edx-platform. This is a rolling list of changes,
in roughly chronological order, most recent first. Add your entries at or near
in roughly chronological order, most recent first. Add your entries at or near
the top. Include a label indicating the component affected.
the top. Include a label indicating the component affected.
Blades: Disallow users to enter video url's in http.
Blades: Fix bug when the speed can only be changed when the video is playing.
Blades: Fix bug when the speed can only be changed when the video is playing.
LMS: Change bulk email implementation to use less memory, and to better handle
LMS: Change bulk email implementation to use less memory, and to better handle
...
...
cms/djangoapps/contentstore/features/transcripts.feature
View file @
6cb5c390
This diff is collapsed.
Click to expand it.
cms/djangoapps/contentstore/views/item.py
View file @
6cb5c390
...
@@ -2,8 +2,9 @@
...
@@ -2,8 +2,9 @@
import
logging
import
logging
from
uuid
import
uuid4
from
uuid
import
uuid4
from
requests.packages.urllib3.util
import
parse_url
from
django.core.exceptions
import
PermissionDenied
from
django.core.exceptions
import
PermissionDenied
,
ValidationError
from
django.contrib.auth.decorators
import
login_required
from
django.contrib.auth.decorators
import
login_required
from
xmodule.modulestore
import
Location
from
xmodule.modulestore
import
Location
...
@@ -107,6 +108,17 @@ def save_item(request):
...
@@ -107,6 +108,17 @@ def save_item(request):
except
ValueError
:
except
ValueError
:
return
JsonResponse
({
"error"
:
"Invalid data"
},
400
)
return
JsonResponse
({
"error"
:
"Invalid data"
},
400
)
field
.
write_to
(
existing_item
,
value
)
field
.
write_to
(
existing_item
,
value
)
if
existing_item
.
category
==
'video'
:
allowedSchemes
=
[
'https'
]
# The entire site is served from https, so browsers with good
# security will reject non-https URLs anyway.
# Also, following video module specific code is here, because front-end
# metadata fields doesn't support validation.
if
metadata_key
==
'html5_sources'
and
not
all
([
parse_url
(
u
)
.
scheme
in
allowedSchemes
for
u
in
value
]):
raise
ValidationError
(
u'HTML5 video sources support following protocols: {0}.'
.
format
(
' '
.
join
(
allowedSchemes
)))
# Save the data that we've just changed to the underlying
# Save the data that we've just changed to the underlying
# MongoKeyValueStore before we update the mongo datastore.
# MongoKeyValueStore before we update the mongo datastore.
existing_item
.
save
()
existing_item
.
save
()
...
...
cms/static/js/views/transcripts/utils.js
View file @
6cb5c390
...
@@ -145,7 +145,8 @@ define(["jquery", "underscore", "jquery.ajaxQueue"], function($, _) {
...
@@ -145,7 +145,8 @@ define(["jquery", "underscore", "jquery.ajaxQueue"], function($, _) {
}
}
var
link
=
document
.
createElement
(
'a'
),
var
link
=
document
.
createElement
(
'a'
),
match
;
allowedProtocols
=
[
'https'
],
match
,
protocol
;
link
.
href
=
url
;
link
.
href
=
url
;
match
=
link
.
pathname
match
=
link
.
pathname
...
@@ -153,7 +154,8 @@ define(["jquery", "underscore", "jquery.ajaxQueue"], function($, _) {
...
@@ -153,7 +154,8 @@ define(["jquery", "underscore", "jquery.ajaxQueue"], function($, _) {
.
pop
()
.
pop
()
.
match
(
/
(
.+
)\.(
mp4|webm
)
$/
);
.
match
(
/
(
.+
)\.(
mp4|webm
)
$/
);
if
(
match
)
{
protocol
=
link
.
protocol
.
slice
(
0
,
-
1
);
if
(
match
&&
$
.
inArray
(
protocol
,
allowedProtocols
)
!==
-
1
)
{
cache
[
url
]
=
{
cache
[
url
]
=
{
video
:
match
[
1
],
video
:
match
[
1
],
type
:
match
[
2
]
type
:
match
[
2
]
...
...
cms/static/js_spec/transcripts/editor_spec.js
View file @
6cb5c390
...
@@ -18,8 +18,8 @@ function ($, Backbone, _, Utils, Editor, MetadataView, MetadataModel, MetadataCo
...
@@ -18,8 +18,8 @@ function ($, Backbone, _, Utils, Editor, MetadataView, MetadataModel, MetadataCo
type
:
MetadataModel
.
VIDEO_LIST_TYPE
,
type
:
MetadataModel
.
VIDEO_LIST_TYPE
,
value
:
[
value
:
[
'http://youtu.be/12345678901'
,
'http://youtu.be/12345678901'
,
'video.mp4'
,
'
https://domain.com/
video.mp4'
,
'video.webm'
'
https://domain.com/
video.webm'
]
]
},
},
DisplayNameEntry
=
{
DisplayNameEntry
=
{
...
@@ -116,7 +116,10 @@ function ($, Backbone, _, Utils, Editor, MetadataView, MetadataModel, MetadataCo
...
@@ -116,7 +116,10 @@ function ($, Backbone, _, Utils, Editor, MetadataView, MetadataModel, MetadataCo
help
:
'A list of html5 sources.'
,
help
:
'A list of html5 sources.'
,
options
:
[],
options
:
[],
type
:
MetadataModel
.
LIST_TYPE
,
type
:
MetadataModel
.
LIST_TYPE
,
value
:
[
'default.mp4'
,
'default.webm'
]
value
:
[
'https://domain.com/default.mp4'
,
'https://domain.com/default.webm'
]
},
},
youtubeEntry
=
{
youtubeEntry
=
{
...
@@ -169,17 +172,14 @@ function ($, Backbone, _, Utils, Editor, MetadataView, MetadataModel, MetadataCo
...
@@ -169,17 +172,14 @@ function ($, Backbone, _, Utils, Editor, MetadataView, MetadataModel, MetadataCo
},
"Defaults never loaded"
,
1000
);
},
"Defaults never loaded"
,
1000
);
runs
(
function
()
{
runs
(
function
()
{
var
displayNameValue
=
collection
[
0
].
getValue
(),
var
displayNameValue
=
collection
[
0
].
getValue
();
videoUrlValue
=
collection
[
1
].
getValue
();
var
videoUrlValue
=
collection
[
1
].
getValue
();
expect
(
displayNameValue
).
toBe
(
'default'
);
expect
(
displayNameValue
).
toBe
(
'default'
);
expect
(
videoUrlValue
).
toEqual
([
expect
(
videoUrlValue
).
toEqual
([
'http://youtu.be/OEoXaMPEzfM'
,
'http://youtu.be/OEoXaMPEzfM'
,
'default.mp4'
,
'
https://domain.com/
default.mp4'
,
'default.webm'
'
https://domain.com/
default.webm'
]);
]);
});
});
});
it
(
'If metadataCollection is not defined'
,
function
()
{
it
(
'If metadataCollection is not defined'
,
function
()
{
...
@@ -190,8 +190,8 @@ function ($, Backbone, _, Utils, Editor, MetadataView, MetadataModel, MetadataCo
...
@@ -190,8 +190,8 @@ function ($, Backbone, _, Utils, Editor, MetadataView, MetadataModel, MetadataCo
expect
(
videoUrlValue
).
toEqual
([
expect
(
videoUrlValue
).
toEqual
([
'http://youtu.be/12345678901'
,
'http://youtu.be/12345678901'
,
'video.mp4'
,
'
https://domain.com/
video.mp4'
,
'video.webm'
'
https://domain.com/
video.webm'
]);
]);
});
});
...
@@ -202,8 +202,8 @@ function ($, Backbone, _, Utils, Editor, MetadataView, MetadataModel, MetadataCo
...
@@ -202,8 +202,8 @@ function ($, Backbone, _, Utils, Editor, MetadataView, MetadataModel, MetadataCo
model
.
setValue
([
model
.
setValue
([
'12345678'
,
'12345678'
,
'default.mp4'
,
'
https://domain.com/
default.mp4'
,
'default.webm'
'
https://domain.com/
default.webm'
]);
]);
transcripts
.
syncBasicTab
(
metadataCollection
,
metadataView
);
transcripts
.
syncBasicTab
(
metadataCollection
,
metadataView
);
...
@@ -213,8 +213,8 @@ function ($, Backbone, _, Utils, Editor, MetadataView, MetadataModel, MetadataCo
...
@@ -213,8 +213,8 @@ function ($, Backbone, _, Utils, Editor, MetadataView, MetadataModel, MetadataCo
expect
(
videoUrlValue
).
toEqual
([
expect
(
videoUrlValue
).
toEqual
([
''
,
''
,
'default.mp4'
,
'
https://domain.com/
default.mp4'
,
'default.webm'
'
https://domain.com/
default.webm'
]);
]);
});
});
});
});
...
@@ -232,16 +232,16 @@ function ($, Backbone, _, Utils, Editor, MetadataView, MetadataModel, MetadataCo
...
@@ -232,16 +232,16 @@ function ($, Backbone, _, Utils, Editor, MetadataView, MetadataModel, MetadataCo
runs
(
function
()
{
runs
(
function
()
{
var
displayNameValue
=
collection
[
0
].
getValue
()
;
var
displayNameValue
=
collection
[
0
].
getValue
()
,
var
subValue
=
collection
[
1
].
getValue
();
subValue
=
collection
[
1
].
getValue
(),
var
html5SourcesValue
=
collection
[
2
].
getValue
();
html5SourcesValue
=
collection
[
2
].
getValue
(),
var
youtubeValue
=
collection
[
3
].
getValue
();
youtubeValue
=
collection
[
3
].
getValue
();
expect
(
displayNameValue
).
toBe
(
'display value'
);
expect
(
displayNameValue
).
toBe
(
'display value'
);
expect
(
subValue
).
toBe
(
'default'
);
expect
(
subValue
).
toBe
(
'default'
);
expect
(
html5SourcesValue
).
toEqual
([
expect
(
html5SourcesValue
).
toEqual
([
'video.mp4'
,
'
https://domain.com/
video.mp4'
,
'video.webm'
'
https://domain.com/
video.webm'
]);
]);
expect
(
youtubeValue
).
toBe
(
'12345678901'
);
expect
(
youtubeValue
).
toBe
(
'12345678901'
);
});
});
...
@@ -259,8 +259,8 @@ function ($, Backbone, _, Utils, Editor, MetadataView, MetadataModel, MetadataCo
...
@@ -259,8 +259,8 @@ function ($, Backbone, _, Utils, Editor, MetadataView, MetadataModel, MetadataCo
expect
(
displayNameValue
).
toBe
(
'default'
);
expect
(
displayNameValue
).
toBe
(
'default'
);
expect
(
subValue
).
toBe
(
'default'
);
expect
(
subValue
).
toBe
(
'default'
);
expect
(
html5SourcesValue
).
toEqual
([
expect
(
html5SourcesValue
).
toEqual
([
'default.mp4'
,
'
https://domain.com/
default.mp4'
,
'default.webm'
'
https://domain.com/
default.webm'
]);
]);
expect
(
youtubeValue
).
toBe
(
'OEoXaMPEzfM'
);
expect
(
youtubeValue
).
toBe
(
'OEoXaMPEzfM'
);
});
});
...
@@ -269,8 +269,8 @@ function ($, Backbone, _, Utils, Editor, MetadataView, MetadataModel, MetadataCo
...
@@ -269,8 +269,8 @@ function ($, Backbone, _, Utils, Editor, MetadataView, MetadataModel, MetadataCo
var
model
=
transcripts
.
collection
.
models
[
1
];
var
model
=
transcripts
.
collection
.
models
[
1
];
model
.
setValue
([
model
.
setValue
([
'video.mp4'
,
'
https://domain.com/
video.mp4'
,
'video.webm'
'
https://domain.com/
video.webm'
]);
]);
transcripts
.
syncAdvancedTab
(
metadataCollection
);
transcripts
.
syncAdvancedTab
(
metadataCollection
);
...
@@ -280,8 +280,8 @@ function ($, Backbone, _, Utils, Editor, MetadataView, MetadataModel, MetadataCo
...
@@ -280,8 +280,8 @@ function ($, Backbone, _, Utils, Editor, MetadataView, MetadataModel, MetadataCo
youtubeValue
=
collection
[
3
].
getValue
();
youtubeValue
=
collection
[
3
].
getValue
();
expect
(
html5SourcesValue
).
toEqual
([
expect
(
html5SourcesValue
).
toEqual
([
'video.mp4'
,
'
https://domain.com/
video.mp4'
,
'video.webm'
'
https://domain.com/
video.webm'
]);
]);
expect
(
youtubeValue
).
toBe
(
''
);
expect
(
youtubeValue
).
toBe
(
''
);
});
});
...
...
cms/static/js_spec/transcripts/utils_spec.js
View file @
6cb5c390
...
@@ -24,17 +24,13 @@ function ($, _, Utils, _str) {
...
@@ -24,17 +24,13 @@ function ($, _, Utils, _str) {
}
(
videoId
)),
}
(
videoId
)),
html5FileName
=
'file_name'
,
html5FileName
=
'file_name'
,
html5LinksList
=
(
function
(
videoName
)
{
html5LinksList
=
(
function
(
videoName
)
{
var
videoTypes
=
[
'mp4'
,
'webm'
],
var
videoTypes
=
[
'mp4'
,
'webm'
],
links
=
[
links
=
[
'http://somelink.com/%s.%s?param=1¶m=2#hash'
,
'https://somelink.com/%s.%s?param=1¶m=2#hash'
,
'http://somelink.com/%s.%s#hash'
,
'https://somelink.com/%s.%s#hash'
,
'http://somelink.com/%s.%s?param=1¶m=2'
,
'https://somelink.com/%s.%s?param=1¶m=2'
,
'http://somelink.com/%s.%s'
,
'https://somelink.com/%s.%s'
'ftp://somelink.com/%s.%s'
,
'https://somelink.com/%s.%s'
,
'somelink.com/%s.%s'
,
'%s.%s'
],
],
data
=
{};
data
=
{};
...
@@ -190,7 +186,12 @@ function ($, _, Utils, _str) {
...
@@ -190,7 +186,12 @@ function ($, _, Utils, _str) {
'http://google.com/somevideo_mp4'
,
'http://google.com/somevideo_mp4'
,
'http://google.com/somevideo:mp4'
,
'http://google.com/somevideo:mp4'
,
'http://google.com/somevideo'
,
'http://google.com/somevideo'
,
'http://google.com/somevideo.webm_'
'http://google.com/somevideo.webm_'
,
'http://somelink.com/video_name.mp4?param=1¶m=2#hash'
,
'http://somelink.com/video_name.webm'
,
'ftp://somelink.com/video_name.mp4'
,
'somelink.com/video_name.webm'
,
'video_name.mp4'
];
];
$
.
each
(
html5WrongUrls
,
function
(
index
,
link
)
{
$
.
each
(
html5WrongUrls
,
function
(
index
,
link
)
{
...
...
cms/static/js_spec/transcripts/videolist_spec.js
View file @
6cb5c390
...
@@ -41,9 +41,9 @@ function ($, _, Utils, VideoList, MessageManager, MetadataView, MetadataModel, A
...
@@ -41,9 +41,9 @@ function ($, _, Utils, VideoList, MessageManager, MetadataView, MetadataModel, A
options
:
[],
options
:
[],
type
:
MetadataModel
.
VIDEO_LIST_TYPE
,
type
:
MetadataModel
.
VIDEO_LIST_TYPE
,
value
:
[
value
:
[
'http://youtu.be/12345678901'
,
'http
s
://youtu.be/12345678901'
,
'video.mp4'
,
'
https://domain.com/
video.mp4'
,
'video.webm'
'
https://domain.com/
video.webm'
]
]
},
},
response
=
JSON
.
stringify
({
response
=
JSON
.
stringify
({
...
@@ -408,8 +408,8 @@ function ($, _, Utils, VideoList, MessageManager, MetadataView, MetadataModel, A
...
@@ -408,8 +408,8 @@ function ($, _, Utils, VideoList, MessageManager, MetadataView, MetadataModel, A
view
.
setValueInEditor
([
view
.
setValueInEditor
([
'http://youtu.be/12345678901'
,
'http://youtu.be/12345678901'
,
'video.mp4'
,
'
https://domain.com/
video.mp4'
,
'video'
'
https://domain.com/
video'
]);
]);
expect
(
view
).
assertIsCorrectVideoList
(
value
);
expect
(
view
).
assertIsCorrectVideoList
(
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