2012-09-05 47 views
0

我有一個上傳嵌入代碼的文本區域。當我發佈嵌入代碼時,它不會發布完整的代碼。 這是我的嵌入代碼

<iframe frameborder="0" width="480" height="308" src="http://www.dailymotion.com/embed/video/xt7dgo?autoplay=0&logo=0&hideInfos=1&start=0&syndication=108944&foreground=%23F7FFFD&highlight=%23FFC300&background=%23171D1B"></iframe> 

這是我的php代碼來得到這個。

public function embeded(){ 
    $this->form_validation->set_rules('video_heading', 'Video heading', 'required|trim|xss_clean'); 
    $this->form_validation->set_rules('embeded', 'Embeded code', 'required|trim|xss_clean'); 
    $this->load->model('videos'); 
    $error['error']=""; 
    if ($this->form_validation->run() == FALSE) 
    { 
     $error['error']= validation_errors(); 
     $this->load->view('sidebar'); 
     $this->load->view('addvideo', $error); 
     $this->load->view('footer'); 
    }else{ 
     //<iframe width="420" height="315" src="http://www.youtube.com/embed/Niiyh3sxwYk" frameborder="0" allowfullscreen></iframe> 
     $plink=$this->videos->processlink($this->input->post('embeded')); 
     $info = array('heading'=>$this->input->post('video_heading'), 
     'status'=>$this->input->post('status'),'video'=>$plink, 
     'comment'=>$this->input->post('comment'),'category'=>$this->input->post('category')); 
     $this->load->model('videos'); 
     $obj= (object)$info; 
     echo "opsted_link".str_replace("syndication","syndicate", $_POST['embeded']); 
     if(isset($_POST['embeded'])) 
     { 
       echo $_POST['embeded'];exit; 
     } 
     //$this->videos->addembededvideo($obj); 
    } 

} 

當我使用它時,我得到了部分像這樣的i幀代碼。

<iframe frameborder="0" width="480" height="308" src="http://www.dailymotion.com/embed/video/xt7dgo?autoplay=0&logo=0&hideInfos=1&start=0&syndicati></iframe> 

我將src中的參數syndication = 108944更改爲syndicator = 108944。

現在我得到完整的網址!

是「聯合」是任何保留字? 爲什麼會發生這種情況?

回答

0

您的輸入有可能陷入XSS過濾器中。這正是XSS濾波器設計的目的;保護您的網站免受跨站點腳本攻擊。嘗試刪除要測試的xss_clean規則,但請注意,以免投入生產。

我的建議是隻通過HTTP發送視頻ID(在你的表格中)。在這個特別的dailymotion視頻中,你可以找到ID:xt7dgo。它實際上是標籤中唯一重要的信息。

其餘的屬性是自動播放,標誌(開或關),hideInfo(開或關),開始......等所有這些屬性可以在服務器上重新創建。使用服務器回顯標記+提交的ID +所有其他屬性。

+0

感謝它是這行$ this-> form_validation-> set_rules('embeded','嵌入代碼','required | trim | xss_clean');我刪除了xss_clean它現在工作正常 – Arun

0

我做了這樣的事情。

這是在我的控制器的方法:

function framex() 
{ 
    $this->load->helper('form'); 
    if(isset($_POST['frame'])) 
    { 
     echo $_POST['frame'];exit; 
    } 
    $this->load->view('deneme'); 
} 

這是視圖頁面:

<?php 
    echo form_open('deneme/framex'); 
?> 

<textarea name="frame"></textarea> 

<?php 
    echo form_submit('submit','Submit'); 
    echo form_close(); 
?> 

它的工作!

+0

它不適用於我 – Arun

0

這是在line 6072nd line_remove_evil_attributes功能System/core/Security.php,存在該錯誤。 xss_clean正在調用它。

$evil_attributes = array('on\w*', 'style', 'xmlns', 'formaction'); 

我甚至不知道它是否是一個錯誤。他們基本上試圖提供針對性的安全措施,因此我想你必須要對此提供安全保護。或者,您可以將「辛迪加」更改爲「辛迪加」(就像您現在所做的那樣),然後在xss_clean之後將其轉換回辛迪加。