[MIRROR] Play Internet Sound sanity checks (#5918)

* Play Internet Sound sanity checks (#36080)

* Play Internet Sound sanity checks

Now checks if the content URL uses http(s) before playing

* HTML is not HTTP: renames regex

* Converted global regexes to procs that return them

* Revert "Converted global regexes to procs that return them"

This reverts commit 2eedbd6982b0c4de943a72c94f92f9d75001c06e.

* Play Internet Sound sanity checks
This commit is contained in:
CitadelStationBot
2018-03-12 07:04:43 -05:00
committed by Poojawa
parent 5a4f65a288
commit 4f3115cfbe
5 changed files with 20 additions and 12 deletions

View File

@@ -74,8 +74,7 @@
if(length(web_sound_input))
web_sound_input = trim(web_sound_input)
var/static/regex/html_protocol_regex = regex("https?://")
if(findtext(web_sound_input, ":") && !findtext(web_sound_input, html_protocol_regex))
if(findtext(web_sound_input, ":") && !findtext(web_sound_input, GLOB.is_http_protocol))
to_chat(src, "<span class='boldwarning'>Non-http(s) URIs are not allowed.</span>")
to_chat(src, "<span class='warning'>For youtube-dl shortcuts like ytsearch: please use the appropriate full url from the website.</span>")
return
@@ -124,6 +123,9 @@
web_sound_url = " "
if(web_sound_url)
if(web_sound_url != " " && !findtext(web_sound_url, GLOB.is_http_protocol))
to_chat(src, "<span class='boldwarning'>BLOCKED: Content URL not using http(s) protocol</span>")
to_chat(src, "<span class='warning'>The media provider returned a content URL that isn't using the HTTP or HTTPS protocol</span>")
for(var/m in GLOB.player_list)
var/mob/M = m
var/client/C = M.client

View File

@@ -125,6 +125,8 @@ GLOBAL_DATUM_INIT(iconCache, /savefile, new("data/iconCache.sav")) //Cache of ic
C << output("[data]", "[window]:ehjaxCallback")
/datum/chatOutput/proc/sendMusic(music, pitch)
if(!findtext(music, GLOB.is_http_protocol))
return
var/list/music_data = list("adminMusic" = url_encode(url_encode(music)))
if(pitch)
music_data["musicRate"] = pitch