Commit 0ad53f60 by Valera Rozuvan

Revert "BLD-408: Don't allow users to enter video url's in http."

This reverts commit 6cb5c390.
parent 93dddf8d
...@@ -22,8 +22,8 @@ Feature: Video Component Editor ...@@ -22,8 +22,8 @@ Feature: Video Component Editor
And I edit the component And I edit the component
#User inputs html5 links with equal extension #User inputs html5 links with equal extension
And I enter a "https://domain.org/123.webm" source to field number 1 And I enter a "123.webm" source to field number 1
And I enter a "https://domain.org/456.webm" source to field number 2 And I enter a "456.webm" source to field number 2
Then I see error message "file_type" Then I see error message "file_type"
# Currently we are working with 2nd field. It means, that if 2nd field # Currently we are working with 2nd field. It means, that if 2nd field
# contain incorrect value, 1st and 3rd fields should be disabled until # contain incorrect value, 1st and 3rd fields should be disabled until
...@@ -35,8 +35,6 @@ Feature: Video Component Editor ...@@ -35,8 +35,6 @@ Feature: Video Component Editor
#User input URL with incorrect format #User input URL with incorrect format
And I enter a "htt://link.c" source to field number 1 And I enter a "htt://link.c" source to field number 1
Then I see error message "url_format" Then I see error message "url_format"
And I enter a "http://domain.org/123.mp4" source to field number 1
Then I see error message "url_format"
# Currently we are working with 1st field. It means, that if 1st field # Currently we are working with 1st field. It means, that if 1st field
# contain incorrect value, 2nd and 3rd fields should be disabled until # contain incorrect value, 2nd and 3rd fields should be disabled until
# 1st field will be filled by correct correct value # 1st field will be filled by correct correct value
...@@ -122,7 +120,7 @@ Feature: Video Component Editor ...@@ -122,7 +120,7 @@ Feature: Video Component Editor
Given I have created a Video component Given I have created a Video component
And I edit the component And I edit the component
And I enter a "https://domain.org/t_not_exist.mp4" source to field number 1 And I enter a "t_not_exist.mp4" source to field number 1
Then I see status message "not found" Then I see status message "not found"
And I see value "" in the field "HTML5 Transcript" And I see value "" in the field "HTML5 Transcript"
...@@ -131,7 +129,7 @@ Feature: Video Component Editor ...@@ -131,7 +129,7 @@ Feature: Video Component Editor
Given I have created a Video component with subtitles "t_not_exist" Given I have created a Video component with subtitles "t_not_exist"
And I edit the component And I edit the component
And I enter a "https://domain.org/t_not_exist.mp4" source to field number 1 And I enter a "t_not_exist.mp4" source to field number 1
Then I see status message "found" Then I see status message "found"
And I see value "t_not_exist" in the field "HTML5 Transcript" And I see value "t_not_exist" in the field "HTML5 Transcript"
...@@ -143,7 +141,7 @@ Feature: Video Component Editor ...@@ -143,7 +141,7 @@ Feature: Video Component Editor
And I enter a "http://youtu.be/t_not_exist" source to field number 1 And I enter a "http://youtu.be/t_not_exist" source to field number 1
Then I see status message "found" Then I see status message "found"
And I enter a "https://domain.org/test_video_name.mp4" source to field number 2 And I enter a "test_video_name.mp4" source to field number 2
Then I see status message "found" Then I see status message "found"
And I see value "t_not_exist" in the field "HTML5 Transcript" And I see value "t_not_exist" in the field "HTML5 Transcript"
...@@ -158,7 +156,7 @@ Feature: Video Component Editor ...@@ -158,7 +156,7 @@ Feature: Video Component Editor
And I click transcript button "import" And I click transcript button "import"
Then I see status message "found" Then I see status message "found"
And I enter a "https://domain.org/t_not_exist.mp4" source to field number 2 And I enter a "t_not_exist.mp4" source to field number 2
Then I see status message "found" Then I see status message "found"
And I see value "t__eq_exist" in the field "HTML5 Transcript" And I see value "t__eq_exist" in the field "HTML5 Transcript"
...@@ -172,12 +170,12 @@ Feature: Video Component Editor ...@@ -172,12 +170,12 @@ Feature: Video Component Editor
And I see button "import" And I see button "import"
And I see button "upload_new_timed_transcripts" And I see button "upload_new_timed_transcripts"
And I enter a "https://domain.org/t_not_exist.mp4" source to field number 2 And I enter a "t_not_exist.mp4" source to field number 2
Then I see status message "not found" Then I see status message "not found"
And I see button "import" And I see button "import"
And I see button "upload_new_timed_transcripts" And I see button "upload_new_timed_transcripts"
And I enter a "https://domain.org/t_not_exist.webm" source to field number 3 And I enter a "t_not_exist.webm" source to field number 3
Then I see status message "not found" Then I see status message "not found"
And I see button "import" And I see button "import"
And I see button "upload_new_timed_transcripts" And I see button "upload_new_timed_transcripts"
...@@ -190,11 +188,11 @@ Feature: Video Component Editor ...@@ -190,11 +188,11 @@ Feature: Video Component Editor
Then I see status message "not found" Then I see status message "not found"
And I see button "disabled_download_to_edit" And I see button "disabled_download_to_edit"
And I see button "upload_new_timed_transcripts" And I see button "upload_new_timed_transcripts"
And I enter a "https://domain.org/t_not_exist.mp4" source to field number 2 And I enter a "t_not_exist.mp4" source to field number 2
Then I see status message "not found" Then I see status message "not found"
And I see button "upload_new_timed_transcripts" And I see button "upload_new_timed_transcripts"
And I see button "disabled_download_to_edit" And I see button "disabled_download_to_edit"
And I enter a "https://domain.org/t_not_exist.webm" source to field number 3 And I enter a "t_not_exist.webm" source to field number 3
Then I see status message "not found" Then I see status message "not found"
And I see button "disabled_download_to_edit" And I see button "disabled_download_to_edit"
And I see button "upload_new_timed_transcripts" And I see button "upload_new_timed_transcripts"
...@@ -211,12 +209,12 @@ Feature: Video Component Editor ...@@ -211,12 +209,12 @@ Feature: Video Component Editor
Then I see status message "found" Then I see status message "found"
And I see button "upload_new_timed_transcripts" And I see button "upload_new_timed_transcripts"
And I enter a "https://domain.org/t_not_exist.mp4" source to field number 2 And I enter a "t_not_exist.mp4" source to field number 2
Then I see status message "found" Then I see status message "found"
And I see button "download_to_edit" And I see button "download_to_edit"
And I see button "upload_new_timed_transcripts" And I see button "upload_new_timed_transcripts"
And I enter a "https://domain.org/t_not_exist.webm" source to field number 3 And I enter a "t_not_exist.webm" source to field number 3
Then I see status message "found" Then I see status message "found"
And I see button "download_to_edit" And I see button "download_to_edit"
And I see button "upload_new_timed_transcripts" And I see button "upload_new_timed_transcripts"
...@@ -231,12 +229,12 @@ Feature: Video Component Editor ...@@ -231,12 +229,12 @@ Feature: Video Component Editor
And I see button "disabled_download_to_edit" And I see button "disabled_download_to_edit"
And I see button "upload_new_timed_transcripts" And I see button "upload_new_timed_transcripts"
And I enter a "https://domain.org/t_not_exist.mp4" source to field number 2 And I enter a "t_not_exist.mp4" source to field number 2
Then I see status message "not found" Then I see status message "not found"
And I see button "disabled_download_to_edit" And I see button "disabled_download_to_edit"
And I see button "upload_new_timed_transcripts" And I see button "upload_new_timed_transcripts"
And I enter a "https://domain.org/t_neq_exist.webm" source to field number 3 And I enter a "t_neq_exist.webm" source to field number 3
Then I see status message "found" Then I see status message "found"
And I see button "download_to_edit" And I see button "download_to_edit"
And I see button "upload_new_timed_transcripts" And I see button "upload_new_timed_transcripts"
...@@ -251,12 +249,12 @@ Feature: Video Component Editor ...@@ -251,12 +249,12 @@ Feature: Video Component Editor
And I see button "import" And I see button "import"
And I see button "upload_new_timed_transcripts" And I see button "upload_new_timed_transcripts"
And I enter a "https://domain.org/t_not_exist.mp4" source to field number 2 And I enter a "t_not_exist.mp4" source to field number 2
Then I see status message "not found" Then I see status message "not found"
And I see button "import" And I see button "import"
And I see button "upload_new_timed_transcripts" And I see button "upload_new_timed_transcripts"
And I enter a "https://domain.org/t_neq_exist.webm" source to field number 3 And I enter a "t_neq_exist.webm" source to field number 3
Then I see status message "not found" Then I see status message "not found"
And I see button "import" And I see button "import"
And I see button "upload_new_timed_transcripts" And I see button "upload_new_timed_transcripts"
...@@ -271,12 +269,12 @@ Feature: Video Component Editor ...@@ -271,12 +269,12 @@ Feature: Video Component Editor
And I see button "import" And I see button "import"
And I see button "upload_new_timed_transcripts" And I see button "upload_new_timed_transcripts"
And I enter a "https://domain.org/t_neq_exist.mp4" source to field number 2 And I enter a "t_neq_exist.mp4" source to field number 2
Then I see status message "not found" Then I see status message "not found"
And I see button "import" And I see button "import"
And I see button "upload_new_timed_transcripts" And I see button "upload_new_timed_transcripts"
And I enter a "https://domain.org/t_not_exist.webm" source to field number 3 And I enter a "t_not_exist.webm" source to field number 3
Then I see status message "not found" Then I see status message "not found"
And I see button "import" And I see button "import"
And I see button "upload_new_timed_transcripts" And I see button "upload_new_timed_transcripts"
...@@ -293,12 +291,12 @@ Feature: Video Component Editor ...@@ -293,12 +291,12 @@ Feature: Video Component Editor
Then I see status message "found" Then I see status message "found"
And I see button "upload_new_timed_transcripts" And I see button "upload_new_timed_transcripts"
And I enter a "https://domain.org/t_neq_exist.mp4" source to field number 2 And I enter a "t_neq_exist.mp4" source to field number 2
Then I see status message "found" Then I see status message "found"
And I see button "download_to_edit" And I see button "download_to_edit"
And I see button "upload_new_timed_transcripts" And I see button "upload_new_timed_transcripts"
And I enter a "https://domain.org/t_not_exist.webm" source to field number 3 And I enter a "t_not_exist.webm" source to field number 3
Then I see status message "found" Then I see status message "found"
And I see button "download_to_edit" And I see button "download_to_edit"
And I see button "upload_new_timed_transcripts" And I see button "upload_new_timed_transcripts"
...@@ -315,12 +313,12 @@ Feature: Video Component Editor ...@@ -315,12 +313,12 @@ Feature: Video Component Editor
Then I see status message "found" Then I see status message "found"
And I see button "upload_new_timed_transcripts" And I see button "upload_new_timed_transcripts"
And I enter a "https://domain.org/t_not_exist.mp4" source to field number 2 And I enter a "t_not_exist.mp4" source to field number 2
Then I see status message "found" Then I see status message "found"
And I see button "download_to_edit" And I see button "download_to_edit"
And I see button "upload_new_timed_transcripts" And I see button "upload_new_timed_transcripts"
And I enter a "https://domain.org/t_neq_exist.webm" source to field number 3 And I enter a "t_neq_exist.webm" source to field number 3
Then I see status message "found" Then I see status message "found"
And I see button "download_to_edit" And I see button "download_to_edit"
And I see button "upload_new_timed_transcripts" And I see button "upload_new_timed_transcripts"
...@@ -330,7 +328,7 @@ Feature: Video Component Editor ...@@ -330,7 +328,7 @@ Feature: Video Component Editor
Given I have created a Video component with subtitles "t__eq_exist" Given I have created a Video component with subtitles "t__eq_exist"
And I edit the component And I edit the component
And I enter a "https://domain.org/t__eq_exist.mp4" source to field number 1 And I enter a "t__eq_exist.mp4" source to field number 1
Then I see status message "found" Then I see status message "found"
And I see button "download_to_edit" And I see button "download_to_edit"
And I see button "upload_new_timed_transcripts" And I see button "upload_new_timed_transcripts"
...@@ -345,7 +343,7 @@ Feature: Video Component Editor ...@@ -345,7 +343,7 @@ Feature: Video Component Editor
And I see button "download_to_edit" And I see button "download_to_edit"
And I see button "upload_new_timed_transcripts" And I see button "upload_new_timed_transcripts"
And I enter a "https://domain.org/test_transcripts.webm" source to field number 3 And I enter a "test_transcripts.webm" source to field number 3
Then I see status message "found" Then I see status message "found"
#20 #20
...@@ -353,7 +351,7 @@ Feature: Video Component Editor ...@@ -353,7 +351,7 @@ Feature: Video Component Editor
Given I have created a Video component with subtitles "t_not_exist" Given I have created a Video component with subtitles "t_not_exist"
And I edit the component And I edit the component
And I enter a "https://domain.org/test_transcripts.mp4" source to field number 1 And I enter a "test_transcripts.mp4" source to field number 1
Then I see status message "not found" Then I see status message "not found"
And I see button "download_to_edit" And I see button "download_to_edit"
And I see button "upload_new_timed_transcripts" And I see button "upload_new_timed_transcripts"
...@@ -361,7 +359,7 @@ Feature: Video Component Editor ...@@ -361,7 +359,7 @@ Feature: Video Component Editor
Then I see status message "uploaded_successfully" Then I see status message "uploaded_successfully"
And I see value "test_transcripts" in the field "HTML5 Transcript" And I see value "test_transcripts" in the field "HTML5 Transcript"
And I enter a "https://domain.org/t_not_exist.webm" source to field number 2 And I enter a "t_not_exist.webm" source to field number 2
Then I see status message "replace" Then I see status message "replace"
And I see choose button "test_transcripts.mp4" number 1 And I see choose button "test_transcripts.mp4" number 1
...@@ -374,7 +372,7 @@ Feature: Video Component Editor ...@@ -374,7 +372,7 @@ Feature: Video Component Editor
Given I have created a Video component with subtitles "t_not_exist" Given I have created a Video component with subtitles "t_not_exist"
And I edit the component And I edit the component
And I enter a "https://domain.org/t_not_exist.mp4" source to field number 1 And I enter a "t_not_exist.mp4" source to field number 1
Then I see status message "found" Then I see status message "found"
And I see button "download_to_edit" And I see button "download_to_edit"
And I see button "upload_new_timed_transcripts" And I see button "upload_new_timed_transcripts"
...@@ -383,13 +381,13 @@ Feature: Video Component Editor ...@@ -383,13 +381,13 @@ Feature: Video Component Editor
And I save changes And I save changes
And I edit the component And I edit the component
And I enter a "https://domain.org/video_name_2.mp4" source to field number 1 And I enter a "video_name_2.mp4" source to field number 1
Then I see status message "use existing" Then I see status message "use existing"
And I see button "use_existing" And I see button "use_existing"
And I click transcript button "use_existing" And I click transcript button "use_existing"
And I see value "video_name_2" in the field "HTML5 Transcript" And I see value "video_name_2" in the field "HTML5 Transcript"
And I enter a "https://domain.org/video_name_3.mp4" source to field number 1 And I enter a "video_name_3.mp4" source to field number 1
Then I see status message "use existing" Then I see status message "use existing"
And I see button "use_existing" And I see button "use_existing"
And I click transcript button "use_existing" And I click transcript button "use_existing"
...@@ -400,7 +398,7 @@ Feature: Video Component Editor ...@@ -400,7 +398,7 @@ Feature: Video Component Editor
Given I have created a Video component with subtitles "t_not_exist" Given I have created a Video component with subtitles "t_not_exist"
And I edit the component And I edit the component
And I enter a "https://domain.org/t_not_exist.mp4" source to field number 1 And I enter a "t_not_exist.mp4" source to field number 1
Then I see status message "found" Then I see status message "found"
And I see button "download_to_edit" And I see button "download_to_edit"
And I see button "upload_new_timed_transcripts" And I see button "upload_new_timed_transcripts"
...@@ -409,17 +407,17 @@ Feature: Video Component Editor ...@@ -409,17 +407,17 @@ Feature: Video Component Editor
And I save changes And I save changes
And I edit the component And I edit the component
And I enter a "https://domain.org/video_name_2.mp4" source to field number 1 And I enter a "video_name_2.mp4" source to field number 1
Then I see status message "use existing" Then I see status message "use existing"
And I see button "use_existing" And I see button "use_existing"
And I click transcript button "use_existing" And I click transcript button "use_existing"
And I see value "video_name_2" in the field "HTML5 Transcript" And I see value "video_name_2" in the field "HTML5 Transcript"
And I enter a "https://domain.org/video_name_3.mp4" source to field number 1 And I enter a "video_name_3.mp4" source to field number 1
Then I see status message "use existing" Then I see status message "use existing"
And I see button "use_existing" And I see button "use_existing"
And I enter a "https://domain.org/video_name_4.mp4" source to field number 1 And I enter a "video_name_4.mp4" source to field number 1
Then I see status message "use existing" Then I see status message "use existing"
And I see button "use_existing" And I see button "use_existing"
And I click transcript button "use_existing" And I click transcript button "use_existing"
...@@ -430,7 +428,7 @@ Feature: Video Component Editor ...@@ -430,7 +428,7 @@ Feature: Video Component Editor
Given I have created a Video component with subtitles "t_not_exist" Given I have created a Video component with subtitles "t_not_exist"
And I edit the component And I edit the component
And I enter a "https://domain.org/t_not_exist.mp4" source to field number 1 And I enter a "t_not_exist.mp4" source to field number 1
Then I see status message "found" Then I see status message "found"
And I see button "download_to_edit" And I see button "download_to_edit"
And I see button "upload_new_timed_transcripts" And I see button "upload_new_timed_transcripts"
...@@ -438,11 +436,11 @@ Feature: Video Component Editor ...@@ -438,11 +436,11 @@ Feature: Video Component Editor
And I save changes And I save changes
And I edit the component And I edit the component
And I enter a "https://domain.org/video_name_2.mp4" source to field number 1 And I enter a "video_name_2.mp4" source to field number 1
Then I see status message "use existing" Then I see status message "use existing"
And I see button "use_existing" And I see button "use_existing"
And I enter a "https://domain.org/video_name_3.webm" source to field number 2 And I enter a "video_name_3.webm" source to field number 2
Then I see status message "use existing" Then I see status message "use existing"
And I see button "use_existing" And I see button "use_existing"
And I click transcript button "use_existing" And I click transcript button "use_existing"
...@@ -453,7 +451,7 @@ Feature: Video Component Editor ...@@ -453,7 +451,7 @@ Feature: Video Component Editor
Given I have created a Video component Given I have created a Video component
And I edit the component And I edit the component
And I enter a "https://domain.org/video_name_1.mp4" source to field number 1 And I enter a "video_name_1.mp4" source to field number 1
And I see status message "not found" And I see status message "not found"
And I upload the transcripts file "test_transcripts.srt" And I upload the transcripts file "test_transcripts.srt"
Then I see status message "uploaded_successfully" Then I see status message "uploaded_successfully"
...@@ -473,7 +471,7 @@ Feature: Video Component Editor ...@@ -473,7 +471,7 @@ Feature: Video Component Editor
Given I have created a Video component Given I have created a Video component
And I edit the component And I edit the component
And I enter a "https://domain.org/video_name_1.mp4" source to field number 1 And I enter a "video_name_1.mp4" source to field number 1
Then I see status message "not found" Then I see status message "not found"
#26 #26
...@@ -481,10 +479,10 @@ Feature: Video Component Editor ...@@ -481,10 +479,10 @@ Feature: Video Component Editor
Given I have created a Video component Given I have created a Video component
And I edit the component And I edit the component
And I enter a "https://domain.org/video_name_1.mp4" source to field number 1 And I enter a "video_name_1.mp4" source to field number 1
And I see status message "not found" And I see status message "not found"
And I enter a "https://domain.org/video_name_2.webm" source to field number 2 And I enter a "video_name_2.webm" source to field number 2
And I see status message "not found" And I see status message "not found"
And I upload the transcripts file "test_transcripts.srt" And I upload the transcripts file "test_transcripts.srt"
Then I see status message "uploaded_successfully" Then I see status message "uploaded_successfully"
...@@ -520,7 +518,7 @@ Feature: Video Component Editor ...@@ -520,7 +518,7 @@ Feature: Video Component Editor
Then I see status message "not found" Then I see status message "not found"
And I see button "upload_new_timed_transcripts" And I see button "upload_new_timed_transcripts"
And I enter a "https://domain.org/video_name_1.mp4" source to field number 2 And I enter a "video_name_1.mp4" source to field number 2
Then I see status message "not found" Then I see status message "not found"
And I see button "upload_new_timed_transcripts" And I see button "upload_new_timed_transcripts"
...@@ -540,7 +538,7 @@ Feature: Video Component Editor ...@@ -540,7 +538,7 @@ Feature: Video Component Editor
Given I have created a Video component with subtitles "t_not_exist" Given I have created a Video component with subtitles "t_not_exist"
And I edit the component And I edit the component
And I enter a "https://domain.org/video_name_1.mp4" source to field number 1 And I enter a "video_name_1.mp4" source to field number 1
Then I see status message "not found" Then I see status message "not found"
And I open tab "Advanced" And I open tab "Advanced"
...@@ -558,7 +556,7 @@ Feature: Video Component Editor ...@@ -558,7 +556,7 @@ Feature: Video Component Editor
Given I have created a Video component Given I have created a Video component
And I edit the component And I edit the component
And I enter a "https://domain.org/video_name_1.mp4" source to field number 1 And I enter a "video_name_1.mp4" source to field number 1
Then I see status message "not found" Then I see status message "not found"
And I upload the transcripts file "chinese_transcripts.srt" And I upload the transcripts file "chinese_transcripts.srt"
...@@ -572,7 +570,7 @@ Feature: Video Component Editor ...@@ -572,7 +570,7 @@ Feature: Video Component Editor
Given I have created a Video component with subtitles "t_not_exist" Given I have created a Video component with subtitles "t_not_exist"
And I edit the component And I edit the component
And I enter a "https://domain.org/video_name_1.mp4" source to field number 1 And I enter a "video_name_1.mp4" source to field number 1
Then I see status message "not found" Then I see status message "not found"
And I open tab "Advanced" And I open tab "Advanced"
...@@ -592,7 +590,7 @@ Feature: Video Component Editor ...@@ -592,7 +590,7 @@ Feature: Video Component Editor
Given I have created a Video component with subtitles "t_not_exist" Given I have created a Video component with subtitles "t_not_exist"
And I edit the component And I edit the component
And I enter a "https://domain.org/t_not_exist.mp4" source to field number 1 And I enter a "t_not_exist.mp4" source to field number 1
Then I see status message "found" Then I see status message "found"
And I open tab "Advanced" And I open tab "Advanced"
...@@ -612,7 +610,7 @@ Feature: Video Component Editor ...@@ -612,7 +610,7 @@ Feature: Video Component Editor
Given I have created a Video component with subtitles "t_not_exist" Given I have created a Video component with subtitles "t_not_exist"
And I edit the component And I edit the component
And I enter a "https://domain.org/t_not_exist.mp4" source to field number 1 And I enter a "t_not_exist.mp4" source to field number 1
Then I see status message "found" Then I see status message "found"
And I save changes And I save changes
...@@ -635,7 +633,7 @@ Feature: Video Component Editor ...@@ -635,7 +633,7 @@ Feature: Video Component Editor
Given I have created a Video component with subtitles "t_not_exist" Given I have created a Video component with subtitles "t_not_exist"
And I edit the component And I edit the component
And I enter a "https://domain.org/video_name_1.mp4" source to field number 1 And I enter a "video_name_1.mp4" source to field number 1
Then I see status message "not found" Then I see status message "not found"
And I upload the transcripts file "chinese_transcripts.srt" And I upload the transcripts file "chinese_transcripts.srt"
......
...@@ -2,9 +2,8 @@ ...@@ -2,9 +2,8 @@
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, ValidationError from django.core.exceptions import PermissionDenied
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
...@@ -108,17 +107,6 @@ def save_item(request): ...@@ -108,17 +107,6 @@ 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()
......
...@@ -145,8 +145,7 @@ define(["jquery", "underscore", "jquery.ajaxQueue"], function($, _) { ...@@ -145,8 +145,7 @@ define(["jquery", "underscore", "jquery.ajaxQueue"], function($, _) {
} }
var link = document.createElement('a'), var link = document.createElement('a'),
allowedProtocols = ['https'], match;
match, protocol;
link.href = url; link.href = url;
match = link.pathname match = link.pathname
...@@ -154,8 +153,7 @@ define(["jquery", "underscore", "jquery.ajaxQueue"], function($, _) { ...@@ -154,8 +153,7 @@ define(["jquery", "underscore", "jquery.ajaxQueue"], function($, _) {
.pop() .pop()
.match(/(.+)\.(mp4|webm)$/); .match(/(.+)\.(mp4|webm)$/);
protocol = link.protocol.slice(0, -1); if (match) {
if (match && $.inArray(protocol, allowedProtocols) !== -1) {
cache[url] = { cache[url] = {
video: match[1], video: match[1],
type: match[2] type: match[2]
......
...@@ -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',
'https://domain.com/video.mp4', 'video.mp4',
'https://domain.com/video.webm' 'video.webm'
] ]
}, },
DisplayNameEntry = { DisplayNameEntry = {
...@@ -116,10 +116,7 @@ function ($, Backbone, _, Utils, Editor, MetadataView, MetadataModel, MetadataCo ...@@ -116,10 +116,7 @@ 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: [ value: ['default.mp4', 'default.webm']
'https://domain.com/default.mp4',
'https://domain.com/default.webm'
]
}, },
youtubeEntry = { youtubeEntry = {
...@@ -172,14 +169,17 @@ function ($, Backbone, _, Utils, Editor, MetadataView, MetadataModel, MetadataCo ...@@ -172,14 +169,17 @@ function ($, Backbone, _, Utils, Editor, MetadataView, MetadataModel, MetadataCo
}, "Defaults never loaded", 1000); }, "Defaults never loaded", 1000);
runs(function() { runs(function() {
var displayNameValue = collection[0].getValue(),
videoUrlValue = collection[1].getValue(); var displayNameValue = collection[0].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',
'https://domain.com/default.mp4', 'default.mp4',
'https://domain.com/default.webm' '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',
'https://domain.com/video.mp4', 'video.mp4',
'https://domain.com/video.webm' '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',
'https://domain.com/default.mp4', 'default.mp4',
'https://domain.com/default.webm' '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([
'', '',
'https://domain.com/default.mp4', 'default.mp4',
'https://domain.com/default.webm' '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();
subValue = collection[1].getValue(), var subValue = collection[1].getValue();
html5SourcesValue = collection[2].getValue(), var html5SourcesValue = collection[2].getValue();
youtubeValue = collection[3].getValue(); var 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([
'https://domain.com/video.mp4', 'video.mp4',
'https://domain.com/video.webm' '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([
'https://domain.com/default.mp4', 'default.mp4',
'https://domain.com/default.webm' '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([
'https://domain.com/video.mp4', 'video.mp4',
'https://domain.com/video.webm' '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([
'https://domain.com/video.mp4', 'video.mp4',
'https://domain.com/video.webm' 'video.webm'
]); ]);
expect(youtubeValue).toBe(''); expect(youtubeValue).toBe('');
}); });
......
...@@ -24,13 +24,17 @@ function ($, _, Utils, _str) { ...@@ -24,13 +24,17 @@ 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 = [
'https://somelink.com/%s.%s?param=1&param=2#hash', 'http://somelink.com/%s.%s?param=1&param=2#hash',
'https://somelink.com/%s.%s#hash', 'http://somelink.com/%s.%s#hash',
'https://somelink.com/%s.%s?param=1&param=2', 'http://somelink.com/%s.%s?param=1&param=2',
'https://somelink.com/%s.%s' 'http://somelink.com/%s.%s',
'ftp://somelink.com/%s.%s',
'https://somelink.com/%s.%s',
'somelink.com/%s.%s',
'%s.%s'
], ],
data = {}; data = {};
...@@ -186,12 +190,7 @@ function ($, _, Utils, _str) { ...@@ -186,12 +190,7 @@ 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&param=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) {
......
...@@ -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: [
'https://youtu.be/12345678901', 'http://youtu.be/12345678901',
'https://domain.com/video.mp4', 'video.mp4',
'https://domain.com/video.webm' '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',
'https://domain.com/video.mp4', 'video.mp4',
'https://domain.com/video' 'video'
]); ]);
expect(view).assertIsCorrectVideoList(value); expect(view).assertIsCorrectVideoList(value);
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment