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
d23e772d
Commit
d23e772d
authored
Dec 12, 2014
by
Waheed Ahmed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed unicode problem if transcript file is not UTF-8 encoded.
TNL-527
parent
28fb3c8e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
3 deletions
+12
-3
common/lib/xmodule/xmodule/video_module/video_handlers.py
+8
-1
lms/djangoapps/courseware/tests/test_video_handlers.py
+4
-2
No files found.
common/lib/xmodule/xmodule/video_module/video_handlers.py
View file @
d23e772d
...
...
@@ -300,7 +300,14 @@ class VideoStudioViewHandlers(object):
if
request
.
method
==
'POST'
:
subtitles
=
request
.
POST
[
'file'
]
save_to_store
(
subtitles
.
file
.
read
(),
unicode
(
subtitles
.
filename
),
'application/x-subrip'
,
self
.
location
)
try
:
file_data
=
subtitles
.
file
.
read
()
unicode
(
file_data
,
"utf-8"
,
"strict"
)
except
UnicodeDecodeError
:
log
.
info
(
"Invalid encoding type for transcript file: {}"
.
format
(
subtitles
.
filename
))
msg
=
_
(
"Invalid encoding type, transcripts should be UTF-8 encoded."
)
return
Response
(
msg
,
status
=
400
)
save_to_store
(
file_data
,
unicode
(
subtitles
.
filename
),
'application/x-subrip'
,
self
.
location
)
generate_sjson_for_all_speeds
(
self
,
unicode
(
subtitles
.
filename
),
{},
language
)
response
=
{
'filename'
:
unicode
(
subtitles
.
filename
),
'status'
:
'Success'
}
return
Response
(
json
.
dumps
(
response
),
status
=
201
)
...
...
lms/djangoapps/courseware/tests/test_video_handlers.py
View file @
d23e772d
...
...
@@ -577,8 +577,10 @@ class TestStudioTranscriptTranslationPostDispatch(TestVideo):
response
=
self
.
item_descriptor
.
studio_transcript
(
request
=
request
,
dispatch
=
'translation/uk'
)
request
=
Request
.
blank
(
'/translation/uk'
,
POST
=
{
'file'
:
(
'filename.srt'
,
SRT_content
.
decode
(
'utf8'
)
.
encode
(
'cp1251'
))})
with
self
.
assertRaises
(
UnicodeDecodeError
):
# Non-UTF8 file content encoding.
response
=
self
.
item_descriptor
.
studio_transcript
(
request
=
request
,
dispatch
=
'translation/uk'
)
# Non-UTF8 file content encoding.
response
=
self
.
item_descriptor
.
studio_transcript
(
request
=
request
,
dispatch
=
'translation/uk'
)
self
.
assertEqual
(
response
.
status_code
,
400
)
self
.
assertEqual
(
response
.
body
,
"Invalid encoding type, transcripts should be UTF-8 encoded."
)
# No language is passed.
request
=
Request
.
blank
(
'/translation'
,
POST
=
{
'file'
:
(
'filename'
,
SRT_content
)})
...
...
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