Remove stream url js escaping and do it on server side instead

This commit is contained in:
drigato 2015-04-08 15:19:22 -04:00
parent 94a7643ebc
commit 78b2631980
2 changed files with 6 additions and 16 deletions

View File

@ -51,7 +51,7 @@ class PlayerController extends Zend_Controller_Action
$this->view->jquery = Application_Common_HTTPHelper::getStationUrl() . "js/libs/jquery-1.10.2.js"; $this->view->jquery = Application_Common_HTTPHelper::getStationUrl() . "js/libs/jquery-1.10.2.js";
$this->view->muses_swf = Application_Common_HTTPHelper::getStationUrl() . "js/airtime/player/muses.swf"; $this->view->muses_swf = Application_Common_HTTPHelper::getStationUrl() . "js/airtime/player/muses.swf";
$this->view->metadata_api_url = Application_Common_HTTPHelper::getStationUrl() . "api/live-info"; $this->view->metadata_api_url = Application_Common_HTTPHelper::getStationUrl() . "api/live-info";
$this->view->station_name = addslashes(Application_Model_Preference::GetStationName()); $this->view->station_name = json_encode(Application_Model_Preference::GetStationName());
$stream = $request->getParam('stream'); $stream = $request->getParam('stream');
$streamData = Application_Model_StreamSetting::getEnabledStreamData(); $streamData = Application_Model_StreamSetting::getEnabledStreamData();
@ -70,7 +70,7 @@ class PlayerController extends Zend_Controller_Action
} else { } else {
$this->view->playerMode = "manual"; $this->view->playerMode = "manual";
$selectedStreamData = $streamData[$stream]; $selectedStreamData = $streamData[$stream];
$this->view->streamURL = $selectedStreamData["url"]; $this->view->streamURL = json_encode($selectedStreamData["url"]);
$this->view->codec = $selectedStreamData["codec"]; $this->view->codec = $selectedStreamData["codec"];
} }
$this->view->availableMobileStreams = json_encode($availableMobileStreams); $this->view->availableMobileStreams = json_encode($availableMobileStreams);

View File

@ -35,21 +35,20 @@
}; };
if (this.playerMode == "manual") { if (this.playerMode == "manual") {
this.settings.url = htmlEscape("<?php echo $this->streamURL ?>"); this.settings.url = "<?php echo $this->streamURL ?>";
this.settings.codec = "<?php echo $this->codec ?>"; this.settings.codec = "<?php echo $this->codec ?>";
} else if (this.playerMode == "auto") { } else if (this.playerMode == "auto") {
this.availableMobileStreamQueue = <?php echo $this->availableMobileStreams?>; this.availableMobileStreamQueue = <?php echo $this->availableMobileStreams?>;
this.availableDesktopStreamQueue = <?php echo $this->availableDesktopStreams?>; this.availableDesktopStreamQueue = <?php echo $this->availableDesktopStreams?>;
var stream = this.getNextAvailableStream(); var stream = this.getNextAvailableStream();
this.settings.url = htmlEscape(stream["url"]); this.settings.url = stream["url"];
this.settings.codec = stream["codec"]; this.settings.codec = stream["codec"];
} }
// Create the Muses player object // Create the Muses player object
MRP.insert(this.settings); MRP.insert(this.settings);
var station_name = htmlEscape("<?php echo $this->station_name?>"); $("p.station_name").html("<?php echo $this->station_name?>");
$("p.station_name").html(station_name);
attachStreamMetadataToPlayer(); attachStreamMetadataToPlayer();
@ -143,7 +142,7 @@
// connection limit reached or problem connecting to stream // connection limit reached or problem connecting to stream
if (value === "0") { if (value === "0") {
var stream = musesPlayer.getNextAvailableStream(); var stream = musesPlayer.getNextAvailableStream();
musesPlayer.setURL(htmlEscape(stream["url"])); musesPlayer.setURL(stream["url"]);
musesPlayer.play(); musesPlayer.play();
} }
} }
@ -218,15 +217,6 @@
setTimeout(attachStreamMetadataToPlayer, time_to_next_track_starts); setTimeout(attachStreamMetadataToPlayer, time_to_next_track_starts);
} }
function htmlEscape(str) {
return String(str)
.replace(/&/g, '&amp;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#39;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;');
}
</script> </script>
<style type="text/css"> <style type="text/css">