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
c4b81111
Commit
c4b81111
authored
Mar 21, 2014
by
David Baumgold
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2963 from louyihua/master
Fix incorrect parse of url in video_module.py
parents
55b0fd08
d76c3dfc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
2 deletions
+20
-2
common/lib/xmodule/xmodule/tests/test_video.py
+13
-1
common/lib/xmodule/xmodule/video_module/video_module.py
+7
-1
No files found.
common/lib/xmodule/xmodule/tests/test_video.py
View file @
c4b81111
...
...
@@ -20,7 +20,7 @@ from mock import Mock
from
.
import
LogicTest
from
lxml
import
etree
from
xmodule.modulestore
import
Location
from
xmodule.video_module
import
VideoDescriptor
,
create_youtube_string
from
xmodule.video_module
import
VideoDescriptor
,
create_youtube_string
,
get_ext
from
.test_import
import
DummySystem
from
xblock.field_data
import
DictFieldData
from
xblock.fields
import
ScopeIds
...
...
@@ -107,6 +107,18 @@ class VideoModuleTest(LogicTest):
'1.50'
:
''
}
)
def
test_get_ext
(
self
):
"""Test get the file's extension in a url without query string."""
filename_str
=
'http://www.example.com/path/video.mp4'
output
=
get_ext
(
filename_str
)
self
.
assertEqual
(
output
,
'mp4'
)
def
test_get_ext_with_query_string
(
self
):
"""Test get the file's extension in a url with query string."""
filename_str
=
'http://www.example.com/path/video.mp4?param1=1&p2=2'
output
=
get_ext
(
filename_str
)
self
.
assertEqual
(
output
,
'mp4'
)
class
VideoDescriptorTest
(
unittest
.
TestCase
):
"""Test for VideoDescriptor"""
...
...
common/lib/xmodule/xmodule/video_module/video_module.py
View file @
c4b81111
...
...
@@ -43,6 +43,13 @@ from .video_utils import create_youtube_string
from
xmodule.modulestore.inheritance
import
InheritanceKeyValueStore
from
xblock.runtime
import
KvsFieldData
from
urlparse
import
urlparse
def
get_ext
(
filename
):
# Prevent incorrectly parsing urls like 'http://abc.com/path/video.mp4?xxxx'.
path
=
urlparse
(
filename
)
.
path
return
path
.
rpartition
(
'.'
)[
-
1
]
log
=
logging
.
getLogger
(
__name__
)
...
...
@@ -259,7 +266,6 @@ class VideoModule(VideoFields, XModule):
track_url
=
None
transcript_download_format
=
self
.
transcript_download_format
get_ext
=
lambda
filename
:
filename
.
rpartition
(
'.'
)[
-
1
]
sources
=
{
get_ext
(
src
):
src
for
src
in
self
.
html5_sources
}
if
self
.
download_video
:
...
...
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