2011-04-11 3 views
1

클릭하면 회의 참석자로 표시됩니다. 링크를 구현하려고합니다. 이 링크는 도우미의 방법이다 :html이 link_to에서 이스케이프되고 있습니다.

def link_to_remote_registration(event_id) 
    down_image = "down_blanco.png" 
    up_image = "up_blanco.png" 

    unless registration.nil? 
     if registration.present == 1 
     up_image = "up_filled.png" 
     elsif registration.present == 0 
     down_image = "down_filled.png" 
     end 
    end 

    link_to_remote_registration = String.new 
    loading_and_complete = "Element.show('indicator_event_"+event_id.to_s+"'); Element.hide('vote_"+event_id.to_s+"')".html_safe 
    complete = "Element.hide('indicator_event_"+event_id.to_s+"'); Element.show('vote_"+event_id.to_s+"')".html_safe 

    link_to_remote_registration = 
     link_to(image_tag(up_image , :id => 'will_not_attend_event_'+ event_id.to_s , border => 0), 
     :url => new_registration_path(:present => 1, :event_id => event_id, :escape => false), 
     :remote => true, 
     :method => :put, 
     :loading => loading_and_complete, 
     :complete => complete) 

    return link_to_remote_registration 
    end 

문제는 내가보기에 링크를 렌더링 할 때 HTML의 일부 링크가 작동하지 만드는 탈출 도착한다는 것입니다.

<a href="/calendar?complete=Element.hide%28%27indicator_event_1%27%29%3B+Element.show%28%27vote_1%27%29&loading=Element.show%28%27indicator_event_1%27%29%3B+Element.hide%28%27vote_1%27%29&method=put&remote=true&url=%2Fregistrations%2Fnew%3Fevent_id%3D1%26present%3D1"> 
<img id="will_not_attend_event_1" border="0" src="/images/up_blanco.png?1198181114" alt="Up_blanco"> 
</a> 

나는 유효한 URL이 아닌 것 같아요. 왜 이런 일이 일어 났는지 궁금합니다. 나는 완전한 HTML 문자열과 로딩 문자열에서 HTML 이스케이프를 호출합니다.

감사

답변

0

당신은 또한 원시() 대신 XSS는 시스템 전체의 비활성화로 사용할 수 있습니다.

raw(image_tag(up_image , :id => 'will_not_attend_event_'+ event_id.to_s , border => 0)) 
관련 문제