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
a637121d
Commit
a637121d
authored
Jan 05, 2017
by
noraiz-anwar
Committed by
GitHub
Jan 05, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #14216 from edx/noraiz/TNL-6197
Error while exporting course with too long filename
parents
6d0af9d4
9c139a87
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
4 deletions
+58
-4
cms/djangoapps/contentstore/tests/test_transcripts_utils.py
+12
-0
cms/static/js/spec/video/transcripts/utils_spec.js
+36
-0
cms/static/js/views/video/transcripts/utils.js
+6
-2
common/lib/xmodule/xmodule/video_module/transcripts_utils.py
+4
-2
No files found.
cms/djangoapps/contentstore/tests/test_transcripts_utils.py
View file @
a637121d
...
...
@@ -9,6 +9,7 @@ from mock import patch, Mock
from
django.test.utils
import
override_settings
from
django.conf
import
settings
from
django.utils
import
translation
from
django.utils.crypto
import
get_random_string
from
nose.plugins.skip
import
SkipTest
...
...
@@ -230,6 +231,17 @@ class TestDownloadYoutubeSubs(SharedModuleStoreTestCase):
self
.
assertEqual
(
html5_ids
[
2
],
'baz.1.4'
)
self
.
assertEqual
(
html5_ids
[
3
],
'foo'
)
def
test_html5_id_length
(
self
):
"""
Test that html5_id is parsed with length less than 255, as html5 ids are
used as name for transcript objects and ultimately as filename while creating
file for transcript at the time of exporting a course.
Filename can't be longer than 255 characters.
150 chars is agreed length.
"""
html5_ids
=
transcripts_utils
.
get_html5_ids
([
get_random_string
(
255
)])
self
.
assertEqual
(
len
(
html5_ids
[
0
]),
150
)
@patch
(
'xmodule.video_module.transcripts_utils.requests.get'
)
def
test_fail_downloading_subs
(
self
,
mock_get
):
...
...
cms/static/js/spec/video/transcripts/utils_spec.js
View file @
a637121d
...
...
@@ -215,6 +215,42 @@ function($, _, Utils, _str) {
});
});
});
describe
(
'Too long arguments '
,
function
()
{
var
longFileName
=
(
function
()
{
var
text
=
''
;
var
possibleChars
=
'abcdefghijklmnopqrstuvwxyz'
;
/* eslint vars-on-top: 0 */
for
(
var
i
=
0
;
i
<
255
;
i
++
)
{
text
+=
possibleChars
.
charAt
(
Math
.
floor
(
Math
.
random
()
*
possibleChars
.
length
));
}
return
text
;
}()),
html5LongUrls
=
(
function
(
videoName
)
{
var
links
=
[
'http://somelink.com/%s?param=1¶m=2#hash'
,
'http://somelink.com/%s#hash'
,
'http://somelink.com/%s?param=1¶m=2'
,
'http://somelink.com/%s'
,
'ftp://somelink.com/%s'
,
'https://somelink.com/%s'
,
'https://somelink.com/sub/sub/%s'
,
'http://cdn.somecdn.net/v/%s'
,
'somelink.com/%s'
,
'%s'
];
return
$
.
map
(
links
,
function
(
link
)
{
return
_str
.
sprintf
(
link
,
videoName
);
});
}(
longFileName
));
$
.
each
(
html5LongUrls
,
function
(
index
,
link
)
{
it
(
link
,
function
()
{
var
result
=
Utils
.
parseHTML5Link
(
link
);
expect
(
result
.
video
.
length
).
toBe
(
150
);
});
});
});
});
it
(
'Method: getYoutubeLink'
,
function
()
{
...
...
cms/static/js/views/video/transcripts/utils.js
View file @
a637121d
...
...
@@ -110,6 +110,7 @@ define(['jquery', 'underscore', 'jquery.ajaxQueue'], function($) {
*/
var
_videoLinkParser
=
(
function
()
{
var
cache
=
{};
var
maxVideoNameLength
=
150
;
return
function
(
url
)
{
if
(
typeof
url
!==
'string'
)
{
...
...
@@ -129,7 +130,10 @@ define(['jquery', 'underscore', 'jquery.ajaxQueue'], function($) {
match
=
link
.
pathname
.
match
(
/
\/{1}([^\/]
+
)\.([^\/]
+
)
$/
);
if
(
match
)
{
cache
[
url
]
=
{
video
:
match
[
1
],
/* avoid too long video name, as it will be used as filename for video's transcript
and a filename can not be more that 255 chars, limiting here to 150.
*/
video
:
match
[
1
].
slice
(
0
,
maxVideoNameLength
),
type
:
match
[
2
]
};
}
else
{
...
...
@@ -139,7 +143,7 @@ define(['jquery', 'underscore', 'jquery.ajaxQueue'], function($) {
match
=
link
.
pathname
.
match
(
/
\/{1}([^\/\.]
+
)
$/
);
if
(
match
)
{
cache
[
url
]
=
{
video
:
match
[
1
],
video
:
match
[
1
]
.
slice
(
0
,
maxVideoNameLength
)
,
type
:
'other'
};
}
...
...
common/lib/xmodule/xmodule/video_module/transcripts_utils.py
View file @
a637121d
...
...
@@ -296,9 +296,11 @@ def copy_or_rename_transcript(new_name, old_name, item, delete_old=False, user=N
def
get_html5_ids
(
html5_sources
):
"""
Helper method to parse out an HTML5 source into the ideas
NOTE: This assumes that '/' are not in the filename
NOTE: This assumes that '/' are not in the filename.
Slices each id by 150, restricting too long strings as video names.
"""
html5_ids
=
[
x
.
split
(
'/'
)[
-
1
]
.
rsplit
(
'.'
,
1
)[
0
]
for
x
in
html5_sources
]
html5_ids
=
[
x
.
split
(
'/'
)[
-
1
]
.
rsplit
(
'.'
,
1
)[
0
][:
150
]
for
x
in
html5_sources
]
return
html5_ids
...
...
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